Well, I'm in the same boat essentially as the person above, but my problem is a bit further back. I'm also using C, and I'm watching the traffic through wireshark. The traffic is going to the site but there's no response coming back.
A couple times I actually did get a full response back from the server, but it was weird. The page elements were being sent back to me like in slow motion, everything was loading at half speed. It took about four seconds for the page to be received (which is too long!). But since I only have the send portions of my socket code up and working, perhaps its the lack of the acknowledgement that's doing that (if that's pertinent whatsoever).
Here is the rough transcript of what I'm sending over:
- Code: Select all
GET /missions/prog/11/index.php HTTP/1.1
Host: http://www.hackthissite.org
User-Agent: [edited]
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Cookie: [edited]
Each of these parts is separated with the "\r\n", excepting the last, which is followed with a "\r\n\r\n". That's literally pasted straight from the wireshark capture.
Any nudges in the right direction? I should mention, it's quite possible I'm doing something wrong that's simple, so don't hesitate with any suggestions that might have slipped my mind. I'm certainly no C socket expert.
If it's not been made clear the step that I'm on, what I'm doing is retrieving the page without going to it manually. Then, I plan on snagging the pertinent text and shifting it. I've got the shift down; it's the connecting part that's irking me.
-- Wed Jun 02, 2010 9:44 pm --
maxflow wrote:hello, i done my programe in c (socket programing), program works it solves the problem, but I can't post the answer, so maybe someone could give me a sample how the post data should look:
POST /missions/prog/11/index.php HTTP 1.0
Referer: http://www.hackthissite.org/missions/prog/11/index.php
Cookie: PHPSESSID=something
Content-Type: application/x-www-form-urlencoded
Content-Length: lenght(solution=answer)
solution=answerwhat i mising?
another problem: to check my data I'm writing it to file, in order to make my program work fester i delete the write to file function and sudenly i get accses veluation at address: 0x0..011
with funktion everything works fine
Thanks.
I can't speak for the writing to file ( ended up doing it entirely in memory, with large char arrays), so I can't help you with that. But for the format for submitting it, I finally got it with the following form for the headers being sent across:
- Code: Select all
POST /missions/prog/11/index.php HTTP/1.1
Host: www.hackthissite.org
User-Agent: [your user agent]
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://www.hackthissite.org/missions/prog/11/
Cookie: [your cookie]
Content-Type: application/x-www-form-urlencoded
Content-Length: 82
[there's a double \r\n\r\n here]
solution=Z8jT4JLYm.&submitbutton=submit++++++++++++%28remaining+time%3A+2+seconds%29
-----------------
I'm unsure of how precisely you're going about things, but one thing that really helped me was to use wireshark to snag what was going across the wire before the point at which I had all my socket code finished. The header code one way or another should look quite similar to that going across the wire.
As others have said, be sure to have your cookie going across in the headers! You can get this and all of the headers by clicking on the communications shown in Wireshark and going to 'follow TCP stream.'
I've got to say, you must have balls of steel to be trying this in C, I found it quite frustrating, but it was worth it in the end. Learned a lot in the process.
Good luck, hope this helps.