Sending Session ID Cookie With Java?

Put your programming skills to the test in these challenges.

Sending Session ID Cookie With Java?

Post by sanddbox on Thu Dec 17, 2009 8:34 pm
([msg=31532]see Sending Session ID Cookie With Java?[/msg])

Anyone know how to send my session id along with my request in java so the site realizes I'm logged in?
Image

HTS User Composition:
95% Male
4.98% Female
.01% Monica
.01% Goat
User avatar
sanddbox
Expert
Expert
 
Posts: 2337
Joined: Sat Jul 04, 2009 5:20 pm
Blog: View Blog (0)


Re: Sending Session ID Cookie With Java?

Post by faazshift on Thu Dec 17, 2009 9:01 pm
([msg=31534]see Re: Sending Session ID Cookie With Java?[/msg])

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.
faazshift
Contributor
Contributor
 
Posts: 516
Joined: Wed Jun 03, 2009 3:55 pm
Location: Riverton, Utah
Blog: View Blog (0)


Re: Sending Session ID Cookie With Java?

Post by sanddbox on Thu Dec 17, 2009 9:27 pm
([msg=31535]see Re: Sending Session ID Cookie With Java?[/msg])

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.
Image

HTS User Composition:
95% Male
4.98% Female
.01% Monica
.01% Goat
User avatar
sanddbox
Expert
Expert
 
Posts: 2337
Joined: Sat Jul 04, 2009 5:20 pm
Blog: View Blog (0)


Re: Sending Session ID Cookie With Java?

Post by faazshift on Thu Dec 17, 2009 9:47 pm
([msg=31536]see Re: Sending Session ID Cookie With Java?[/msg])

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!
faazshift
Contributor
Contributor
 
Posts: 516
Joined: Wed Jun 03, 2009 3:55 pm
Location: Riverton, Utah
Blog: View Blog (0)


Re: Sending Session ID Cookie With Java?

Post by sanddbox on Thu Dec 17, 2009 11:14 pm
([msg=31540]see Re: Sending Session ID Cookie With Java?[/msg])

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.
Image

HTS User Composition:
95% Male
4.98% Female
.01% Monica
.01% Goat
User avatar
sanddbox
Expert
Expert
 
Posts: 2337
Joined: Sat Jul 04, 2009 5:20 pm
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests