Can't do Timed 2 (Python)
I finished Timed 8 no problem, and as far as I can tell, the only difference between 8 and 2 is that in Timed 2 you have to submit two pieces of information, technically, and to index.php?check instead of just index.php.
Otherwise I see no difference in how to submit the answer between these two challenges. I'm confident my Python script up to the submission is correct. Can I PM someone? Or would posting parts of the Python script here not be too much of a spoiler?
Mechanize looks cool, but I'll need to learn it. Hopefully it won't take me as long to finish this challenge as I'd need to learn a module :D
Mmmm yeah could help other people.
[php]
import urllib import urllib2 import re
user_agent = 'Mozilla/5.0' cookie = "fusion_visited=TRUE; fusion_user=fusion user number; PHPSESSID=php session id number;"
starturl = "http://www.hellboundhackers.org/challenges/timed/timed2/index.php" endurl = "http://www.hellboundhackers.org/challenges/timed/timed2/index.php?check" headers={'User-Agent' : user_agent , 'Cookie' : cookie}
req = urllib2.Request(starturl,headers={'User-Agent' : user_agent , 'Cookie' : cookie}) response = urllib2.urlopen(req) results = response.read()
startpoint = re.finditer('your string is: ', results)
for i in startpoint: end = i.end()
## RECORD RANDOM STRING
randomstring = None
number = None
for index in results[end:]:
if re.match("[a-zA-Z0-9]", index):
if randomstring == None:
randomstring = index
else:
randomstring = randomstring + index
if re.match("[0-9]", index):
if number == None:
number = index
int(number)
else:
number = int(number) + int(index)
else:
continue
else:
totalsum = number
break
print print "randomstring is:" print randomstring print print "totalsum is:" print totalsum print
values={'submit':'Check', 'ans':str(totalsum)} data = urllib.urlencode(values)
print "data is:" print data print
req = urllib2.Request(endurl, data, headers)
req = urllib2.Request(endurl, data, headers={'User-Agent' : user_agent , 'Cookie' : cookie}) print req.get_method()
urllib2.urlopen(req) [/php]
It's longer than it needs to be in some places because I kept using print statements and trying different things to figure out what's wrong. Dunno where to go from here. Any help would be great!
Yes. In the code it sets ans to the value of totalsum, converted to a string. I've gotten rid of most of the print statements and kept one that reported data, and data is being sent with ans set to totalsum when the script runs, too. (Ex. data = "ans=83&submit=Check" ) Still isn't accepted, though. Status of the response is 200, also.