Page 1 of 1

Sending Session ID Cookie With Java?

PostPosted: Thu Dec 17, 2009 8:34 pm
by sanddbox
Anyone know how to send my session id along with my request in java so the site realizes I'm logged in?

Re: Sending Session ID Cookie With Java?

PostPosted: Thu Dec 17, 2009 9:01 pm
by faazshift
Well, you have to send the cookie containing your session id. In the case of this site, its called PHPSESSID. You send it as part of the cookie header. For example (look at last line):
Code: Select all
GET /forums/posting.php?mode=reply&f=19&t=4423 HTTP/1.0
Host: www.hackthissite.org
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091107 Gentoo Firefox/3.5.5 GTB6
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: 300
Connection: keep-alive
Referer: http://www.hackthissite.org/forums/viewtopic.php?f=19&t=4423
Cookie: some_cookie=text; another_cookie=blah; PHPSESSID=EDITED


Im not sure how to do that in java, but basically just send the session id cookie.

Re: Sending Session ID Cookie With Java?

PostPosted: Thu Dec 17, 2009 9:27 pm
by sanddbox
faazshift wrote:Well, you have to send the cookie containing your session id. In the case of this site, its called PHPSESSID. You send it as part of the cookie header. For example (look at last line):
Code: Select all
GET /forums/posting.php?mode=reply&f=19&t=4423 HTTP/1.0
Host: www.hackthissite.org
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091107 Gentoo Firefox/3.5.5 GTB6
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: 300
Connection: keep-alive
Referer: http://www.hackthissite.org/forums/viewtopic.php?f=19&t=4423
Cookie: some_cookie=text; another_cookie=blah; PHPSESSID=EDITED


Im not sure how to do that in java, but basically just send the session id cookie.


I understand that part; I'm just not sure exactly how to send it.

Re: Sending Session ID Cookie With Java?

PostPosted: Thu Dec 17, 2009 9:47 pm
by faazshift
Ah. In php, python, c++, etc, you create a socket, connect it to the webserver, write the request headers, and read the response. Doing a quick google search ('java sockets'), I found one of several step-by-step tutorials: http://www.devarticles.com/c/a/Java/Socket-Programming-in-Java/. Hope this helps!

Re: Sending Session ID Cookie With Java?

PostPosted: Thu Dec 17, 2009 11:14 pm
by sanddbox
faazshift wrote:Ah. In php, python, c++, etc, you create a socket, connect it to the webserver, write the request headers, and read the response. Doing a quick google search ('java sockets'), I found one of several step-by-step tutorials: http://www.devarticles.com/c/a/Java/Socket-Programming-in-Java/. Hope this helps!


Thanks.