Follow us on Twitter!
The measure of a mans life is not how well he dies, but how well he lives.
Saturday, August 19, 2017
Navigation
Home
 Find:
 Information:
Learn
Communicate
Submit
Shop
Challenges
 Exploit:
 Programming:
 Think:
 Track:
 Patch:
 Other:
 Need Help?
Other
Members Online
Total Online: 65
Guests Online: 64
Members Online: 1

Registered Members: 101563
Newest Member: smox010101
Latest Articles
View Thread

HellBound Hackers | Challenges | Timed Challenges

Author

Can't do Timed 2 (Python)

Serosin
Member



Posts: 18
Location:
Joined: 31.07.13
Rank:
Uber Elite
Posted on 29-03-17 19:45
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?


i1287.photobucket.com/albums/a629/Serosin/SerosinGCircuits500x208_zps71acc69b.png
Author

RE: Can't do Timed 2 (Python)

_spartax_
Member



Posts: 30
Location: SYSTEM
Joined: 03.06.16
Rank:
HBH Guru
Posted on 29-03-17 19:57
you may try using mechanize library


Author

RE: Can't do Timed 2 (Python)

Huitzilopochtli
Member



Posts: 1531
Location:
Joined: 19.02.13
Rank:
God
Posted on 29-03-17 21:12
You can just post the code if you want, rather than being a spoiler it's more likely it'll help anyone else who has the same issue in the future.

Edited by Huitzilopochtli on 29-03-17 21:34
Author

RE: Can't do Timed 2 (Python)

Serosin
Member



Posts: 18
Location:
Joined: 31.07.13
Rank:
Uber Elite
Posted on 29-03-17 22:24
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
  1. <?php
  2.  
  3.  
  4. import urllib
  5. import urllib2
  6. import re
  7.  
  8. user_agent = 'Mozilla/5.0'
  9. cookie = "fusion_visited=TRUE; fusion_user=fusion user number; PHPSESSID=php session id number;"
  10.  
  11. starturl = "http://www.hellboundhackers.org/challenges/timed/timed2/index.php"
  12. endurl = "http://www.hellboundhackers.org/challenges/timed/timed2/index.php?check"
  13. headers={'User-Agent' : user_agent , 'Cookie' : cookie}
  14.  
  15. req = urllib2.Request(starturl,headers={'User-Agent' : user_agent , 'Cookie' : cookie})
  16. response = urllib2.urlopen(req)
  17. results = response.read()
  18.  
  19. startpoint = re.finditer('your string is: ', results)
  20.  
  21. for i in startpoint:
  22.     end = i.end()
  23.  
  24.     ## RECORD RANDOM STRING
  25.     randomstring = None
  26.     number = None
  27.     for index in results[end:]:
  28.         if re.match("[a-zA-Z0-9]", index):
  29.             if randomstring == None:
  30.                 randomstring = index
  31.             else:
  32.                 randomstring = randomstring + index
  33.             if re.match("[0-9]", index):
  34.                 if number == None:
  35.                     number = index
  36.                     int(number)
  37.                 else:
  38.                     number = int(number) + int(index)
  39.             else:
  40.                 continue
  41.         else:
  42.             totalsum = number
  43.             break
  44. print
  45. print "randomstring is:"
  46. print randomstring
  47. print
  48. print "totalsum is:"
  49. print totalsum
  50. print
  51.  
  52. values={'submit':'Check',
  53.     'ans':str(totalsum)}
  54. data = urllib.urlencode(values)
  55.  
  56. print "data is:"
  57. print data
  58. print
  59. # req = urllib2.Request(endurl, data, headers)
  60. req = urllib2.Request(endurl, data, headers={'User-Agent' : user_agent , 'Cookie' : cookie})
  61. print req.get_method()
  62.  
  63. urllib2.urlopen(req)
  64.  
  65. ?>


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!


i1287.photobucket.com/albums/a629/Serosin/SerosinGCircuits500x208_zps71acc69b.png

Edited by Serosin on 30-03-17 01:39
Author

RE: Can't do Timed 2 (Python)

rex_mundi
☆ Lucifer ☆



Posts: 2005
Location: Scotland
Joined: 20.02.08
Rank:
God
Posted on 30-03-17 00:35
I changed those code tags to php ones, they're not ideal but it'll display it better that the code tags do. Thumbs Up
U N ⓡⓔⓧ_ⓜⓤⓝⓓⓘ
Author

RE: Can't do Timed 2 (Python)

Serosin
Member



Posts: 18
Location:
Joined: 31.07.13
Rank:
Uber Elite
Posted on 30-03-17 01:38
Great! yeah the code was kinda... small in the preview, but I wasn't aware of the php option. Thanks!
Author

RE: Can't do Timed 2 (Python)

rex_mundi
☆ Lucifer ☆



Posts: 2005
Location: Scotland
Joined: 20.02.08
Rank:
God
Posted on 30-03-17 03:25
I'm at work so I can only run it on my android, but everything looks ok right up to the part where it posts.

I can't tell on here, but check your data, is it posting the submit and ans= along with the totalsum ?
U N ⓡⓔⓧ_ⓜⓤⓝⓓⓘ
Author

RE: Can't do Timed 2 (Python)

Serosin
Member



Posts: 18
Location:
Joined: 31.07.13
Rank:
Uber Elite
Posted on 30-03-17 03:48
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.

Edited by Serosin on 30-03-17 03:50
Author

RE: Can't do Timed 2 (Python)

Huitzilopochtli
Member



Posts: 1531
Location:
Joined: 19.02.13
Rank:
God
Posted on 30-03-17 05:12
You should use "requests" for Python as it's awesome for working with sessions, and it's probably an issue with cookies on the final POST that's causing the problem.
Author

RE: Can't do Timed 2 (Python)

Serosin
Member



Posts: 18
Location:
Joined: 31.07.13
Rank:
Uber Elite
Posted on 30-03-17 06:15
Ok I got it. It worked.

I copied the lines concerning values, encoding, and POST submission from the script I used for Timed 3. I also changed the endurl to use https instead of http. Whatever.

Anyway, thanks for the help everyone.

GrinThumbs Up