Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Timed 2, POST not submitting (Python)


Xunxen's Avatar
Member
0 0

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.


techb's Avatar
Member
0 0

look in the codebank, I posted an HBH class that will help you understand.


Xunxen's Avatar
Member
0 0

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.


techb's Avatar
Member
0 0

I didn't say use it, just look at it to see what is going on and how to handle cookies and what-nots.


Xunxen's Avatar
Member
0 0

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.


Xunxen's Avatar
Member
0 0

elmiguel wrote: You should check out this: http://www.hellboundhackers.org/articles/904-Using-Python-for-timed-challenges..html;) 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.


j4m32's Avatar
Member
0 0

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 script 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,


Xunxen's Avatar
Member
0 0

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.


ghost's Avatar
0 0

Xunxen wrote: 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.

You can PM me.


Xunxen's Avatar
Member
0 0

Thanks for the help. I'm just going to do these with GM instead of Python.


techb's Avatar
Member
0 0

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.


elmiguel's Avatar
Member
2,795 1

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.