1

I'm working with a website that uses a simple CAPTCHA and I'm looking to try and submit data into the CAPTCHA's entry field and then see what the response is. Eventually, I plan on trying to see if I can do a Padding Oracle attack. After some digging on the website's source I'm fairly sure that the line in the form I need to be dealing with is:

<input type="text" name="login_captcha" size="12" maxlength="6" />&nbsp; &nbsp;  </p>

So I did some digging on StackOverflow to learn how to do this and so far I've made:

Send = "The data I want to submit"
url = 'www.website.com'
values = {'login_captcha' : Send}

data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
print the_page

But it doesn't seem to work. Everything I've read so far seems to say this is the way to do it but it doesn't seem to be doing anything. Does anything seem out of order here?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
OneManRiot
  • 941
  • 3
  • 8
  • 22
  • The python part seems alright. You most likely are hitting an issue somewhere else. Try logging the request with Wireshark or tcpdump, I'm sure python sends it as a POST request. – Pritam Baral Mar 14 '14 at 20:04

3 Answers3

0

first of all - you want submit a form, so verify your url. in question it seems like a url of domain, not url of form (action parameter)

secend optional - your site can detect that your code is not browser, but you can fool it - just set user-agent, referrer, or sometimes cookies

third: debug it yourself with tool like curl and so on.

code above is correct., but remember about encoding (url and data).

Sławomir Lenart
  • 7,543
  • 4
  • 45
  • 61
  • When you say remember the encoding...I had use base64.b64decode(STUFF) in order to get the values I wanted from the website in a workable state. I assumed that I had to Send = base64.b64encode(Send) for the data that I'm passing into the form, correct? Or are you talking about some other part of encoding? – OneManRiot Mar 15 '14 at 01:15
0

What did you mean by didn't work? This doesn't even run in my Python 2.7

url = 'www.website.com'

So add http:// at your url and it should work.

url = 'http://www.website.com'
Sabuj Hassan
  • 38,281
  • 14
  • 75
  • 85
0

I tried the code changing only the URL and the parameters in order to test it with a system in production and ti works without any problem. You should check that the url is the proper one, as this is only a domain. Also, check that your script on the server can read/answer requests sent by POST method.

Javier
  • 1,027
  • 14
  • 23
  • You were right about the URL! I needed to be sending the request to the URL of the "action" in the form. I got that by going back to the source and rightclick->get link location on the action. Instead, I was trying to send the form to the main page which did nothing for me. Big thanks! – OneManRiot Mar 15 '14 at 00:53