| Author |
Timed 2, POST not submitting (Python) |
Xunxen
Member

Posts: 30
Location:
Joined: 06.03.11 Rank: HBH Guru |
|
I managed to get the first challenge to work in essentially the same way I'm trying to do this one, but when my program submits the answer, I just get back the source of the /challenges/timed/timed2/index.php file, including a new hash.
is there someone I can PM for help, because I don't think I can post any of my code without giving a spoiler.
|
|
| Author |
RE: Timed 2, POST not submitting (Python) |
techb
Member

Posts: 384
Location:
Joined: 15.02.09 Rank: Hacker Level 2 |
|
look in the codebank, I posted an HBH class that will help you understand.
|
|
| Author |
RE: Timed 2, POST not submitting (Python) |
Xunxen
Member

Posts: 30
Location:
Joined: 06.03.11 Rank: HBH Guru |
|
I'm kind of hoping to get my code working, I've already started over from scratch once, hoping it was something I would notice if I typed it again. Besides that, I wanted an opportunity to learn more about handling internet access in python. While using your code would be easier, it would rob me of a chance to learn more.
|
|
| Author |
RE: Timed 2, POST not submitting (Python) |
techb
Member

Posts: 384
Location:
Joined: 15.02.09 Rank: Hacker Level 2 |
|
I didn't say use it, just look at it to see what is going on and how to handle cookies and what-nots.
|
|
| Author |
RE: Timed 2, POST not submitting (Python) |
Xunxen
Member

Posts: 30
Location:
Joined: 06.03.11 Rank: HBH Guru |
|
I'm just going to go back to reading about Python because your code kind of confuses me. I just started learning Python last night.
|
|
| Author |
RE: Timed 2, POST not submitting (Python) |
elmiguel
Member

Posts: 132
Location: Your Computer
Joined: 12.12.07 Rank: God |
|
You should check out this: http://www.hellboundhackers.org/articles/904-Using-Python-for-timed-challenges..html
The philosophy of one century is the common sense of the next. -Fortune Cookie
I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor
|
|
| Author |
RE: Timed 2, POST not submitting (Python) |
Xunxen
Member

Posts: 30
Location:
Joined: 06.03.11 Rank: HBH Guru |
|
That was the first place I checked when I started having problems. some of the code mentioned is just wrong, for instance urllib2 is not callable, I had to use urllib2.Request.
other than that, I'm going exactly by that article and it's not working.
what I'm confused about is I'm not getting "YOU MUST BE LOGGED IN TO PLAY" and I'm not getting "No off site posts" I'm just getting the page back. My code is just completely ignoring my POST request.
I tried techb's code and as is it works, but when I try to code only the parts that seem to be doing something, it goes back to ignoring my POST data.
|
|
| Author |
RE: Timed 2, POST not submitting (Python) |
j4m32
Member
Posts: 81
Location:
Joined: 01.05.10 Rank: God |
|
As I know not one iota about Python networking...
I'd say the easiest way to debug this would be to just run a quick packet sniff along side running the scblockedript to make sure the HTTP request is not mal-formed.
1) Take a look at the stream and see whether there was a HTTP response/TCP close whatever.
2) Then, load up your browser of preference, load the page and compare the two requests side by side.
Often a HTTP server will reject, for example:
i) A HTTP/1.0 requests since it's a bit out dated and only allow HTTP/1.1 - not entriely accurate but hey...
ii) If they appear, on first glance, to be practially the same, check your line feeds very carefully, look at the Hex dump if necessary.
At the end of a POST request with the string of POSTed varibles, there shouldn't be another CRLF - this sometimes causes problems in a HTTP request too (from what I can remember).
Hope this helps you find the error...
Jim, |
|
| Author |
RE: Timed 2, POST not submitting (Python) |
Xunxen
Member

Posts: 30
Location:
Joined: 06.03.11 Rank: HBH Guru |
|
I ran a packet sniffer and it's showing the post data as the same as for my browser. also, it's using HTTP/1.1
the only CRLF is after the headers, where it should be.
|
|
| Author |
RE: Timed 2, POST not submitting (Python) |
Xunxen
Member

Posts: 30
Location:
Joined: 06.03.11 Rank: HBH Guru |
|
Thanks for the help. I'm just going to do these with GM instead of Python.
|
|
| Author |
RE: Timed 2, POST not submitting (Python) |
techb
Member

Posts: 384
Location:
Joined: 15.02.09 Rank: Hacker Level 2 |
|
Like I stated before, you need to be able to handle cookies. Also, you need a different user-agent. The web doesn't like programs accessing their pages.
|
|
| Author |
RE: Timed 2, POST not submitting (Python) |
elmiguel
Member

Posts: 132
Location: Your Computer
Joined: 12.12.07 Rank: God |
|
That article was written when Python 2.6 was new. There could be some changes on how the module is called in later versions. But as techb states: it is all about how you handle your cookies, and you need to pass your user agent like this: User-agent: Mozilla, or whatever, just make sure its User-agent not User-Agent as the latter is for exact specification of the agent as the preceding is for custom agents. Also, make sure you add the referrer to your request.
The philosophy of one century is the common sense of the next. -Fortune Cookie
I would like to thank a few friends that I have made here that helped me and deserve to be mentioned:
System_Meltdown, Futility, nvrlivenvrdie, Mastergamer, TrueHacker, S1L3NTKn1GhT, Reelix, ynori7, Demons Halo, kryptor
|
|