
# Docker-basiertes Sicherheitslabor zur Demonstration von Apache Struts2 S2-045 (CVE-2017-5638) Ausnutzung und Verteidigung, mit verwundbaren und gepatchten Anwendungen sowie WAF-Schutz für praxisnahes Training.
Ein Docker-basiertes Sicherheitslabor, das sowohl Exploitation als auch Abwehr der Apache Struts2 S2-045-Sicherheitslücke (CVE-2017-5638) demonstriert. Dieses Labor umfasst:
⚠️ Sicherheitswarnung: Dieses Labor enthält funktionsfähige Exploits und verwundbaren Code. Nur in isolierten Umgebungen verwenden. Nicht öffentlichen Netzwerken aussetzen.
┌─────────────────────────────────────────────────────────────┐
│ Host (127.0.0.1 only) │
├─────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ Simulator │───▶│ Nginx Proxy │ │
│ │ (curl-based) │ │ + WAF Rules │ │
│ └─────────────────┘ └────────┬────────┘ │
│ │ │
│ ┌───────┴────────┐ │
│ │ │ │
│ ┌───────▼──────┐ ┌───────▼──────┐ │
│ │ Defense App │ │ Vulnerable │ │
│ │ (Struts 6.3) │ │ App (2.3.31) │ │
│ │ Port: 8080 │ │ Port: 8081 │ │
│ └──────────────┘ └──────────────┘ │
│ │
│ ┌─────────────────┐ │
│ │ Exploit │───▶ Vulnerable App (8081) │
│ │ Container │ │
│ └─────────────────┘ │
│ │
│ Logs mounted to: ./logs/nginx/, ./logs/app/, │
│ ./logs/app-vulnerable/ │
└─────────────────────────────────────────────────────────────┘
| Container | Zweck | Port |
|---|---|---|
nginx | Reverse-Proxy mit WAF-Regeln, Ratenbegrenzung | 127.0.0.1:8080 |
app | Tomcat 9 + Struts 6.3.x (gepatcht, Abwehr-Labor) | Nur intern |
app-vulnerable | Tomcat 9 + Struts 2.3.31 (verwundbar, für Exploitation) | 127.0.0.1:8081 |
exploit | Container zur Exploitation-Demonstration | N/A |
simulator | Sendet Testanfragen (harmlose + verdächtige Muster) | N/A |
# Clone the repository
git clone https://github.com/ACharaf06/cybersec.git
cd cybersec
# Build all containers (this may take several minutes on first run)
docker compose build
# Start the defense lab (nginx + patched app)
docker compose up -d nginx app
# Start the vulnerable app (for exploitation demo)
docker compose up -d app-vulnerable
# Verify services are running
docker compose ps
# Wait for services to be healthy (about 60 seconds)
sleep 60
# Check health endpoints
curl http://127.0.0.1:8080/struts-lab/health # Defense lab
curl http://127.0.0.1:8081/struts-lab/health # Vulnerable app
Erwartete Ausgabe:
"status":"healthy" und "strutsVersion":"6.3.0.2 (gepatcht – nicht anfällig für S2-045)""status":"healthy" und "strutsVersion":"2.3.31 (VULNERABLE to S2-045)"# Run the simulator container (tests defense mechanisms)
docker-compose run --rm simulator
# Or run individual tests manually:
# Legitimate upload
curl -X POST -F "[email protected]" http://127.0.0.1:8080/struts-lab/upload
# Suspicious Content-Type (will be blocked by WAF)
curl -v -X POST \
-H "Content-Type: multipart/form-data; boundary=----SUSPICIOUS" \
http://127.0.0.1:8080/struts-lab/upload
# Run the exploit container (demonstrates S2-045 exploitation)
docker-compose --profile exploit run --rm exploit
# Or use the Python exploit script directly
python3 exploit/exploit.py http://127.0.0.1:8081/struts-lab 'whoami'
# Or use the bash script
./exploit/demo_exploit.sh
⚠️ Warnung: Die verwundbare Anwendung ist absichtlich ausnutzbar. Nur in isolierten Umgebungen ausführen.
# Defense lab logs
tail -f logs/nginx/access.log # Nginx access logs
tail -f logs/nginx/error.log # WAF blocks
tail -f logs/app/struts-lab.log # Defense app logs
# Vulnerable app logs
tail -f logs/app-vulnerable/struts-lab.log # Vulnerable app logs
# All logs combined
docker-compose logs -f
Legitime Anfrage:
200-AntwortINFO-Level Upload-VerarbeitungsmeldungVerdächtige/fehlerhafte Anfrage:
403 Forbidden oder 400 Bad RequestErfolgreiche Exploitation:
Log-Beispiele:
Nginx blockiert verdächtigen Content-Type (Abwehr-Labor):
[WAF] Blocked suspicious Content-Type pattern - Request ID: abc123
App protokolliert Anfrage-Metadaten (Abwehr-Labor):
[REQUEST] ID=abc123 Content-Type=multipart/form-data Method=POST URI=/upload
[UPLOAD] Processing file upload for request abc123
Erfolgreiche Exploitation (Verwundbare App):
HTTP/1.1 200 OK
...
root
(Command output appears in response body)
| Merkmal | Verwundbare App (Port 8081) | Abwehr-Labor (Port 8080) |
|---|---|---|
| Struts Version | 2.3.31 (verwundbar) | 6.3.0.2 (gepatcht) |
| WAF-Schutz | ❌ Kein | ✅ Nginx-WAF-Regeln |
| Ratenbegrenzung | ❌ Kein | ✅ 10 Anfragen/s |
| Anfragegrößenbegrenzungen | ❌ Kein | ✅ 10 MB Body, 8 KB Header |
| Sicherheitsprotokollierung | ⚠️ Minimal | ✅ Umfassend |
| OGNL-Injection | ✅ Ausnutzbar | ❌ Blockiert/Gepatcht |
| RCE möglich | ✅ Ja | ❌ Nein |
| Anwendungsfall | Exploitation-Demo | Abwehr-Schulung |
127.0.0.1 gebunden (kein externer Zugriff)S2-045 (CVE-2017-5638) war eine kritische Sicherheitslücke in Apache Struts2 Versionen 2.3.5 - 2.3.31 und 2.5 - 2.5.10, bei der:
Die verwundbare App (Port 8081) demonstriert diese Sicherheitslücke. Das Abwehr-Labor (Port 8080) zeigt, wie man sich dagegen schützt.
.
├── docker-compose.yml # Container orchestration
├── README.md # This file
├── EXPLOITATION_GUIDE.md # Detailed exploitation guide
├── TECHNICAL_DETAILS.md # Technical implementation details
├── GLOSSARY.md # Security terms glossary
├── nginx/
│ ├── nginx.conf # Main nginx configuration
│ └── waf-rules.conf # WAF rules for S2-045 patterns
├── app/ # Defense lab (patched)
│ ├── Dockerfile # Tomcat + Maven build
│ └── struts-app/
│ ├── pom.xml # Maven project (Struts 6.3.x)
│ └── src/main/
│ ├── java/ # Action classes
│ ├── resources/ # Struts + Log4j config
│ └── webapp/ # JSP views + web.xml
├── app-vulnerable/ # Vulnerable app (for exploitation)
│ ├── Dockerfile # Tomcat + Maven build
│ └── struts-app/
│ ├── pom.xml # Maven project (Struts 2.3.31)
│ └── src/main/
│ ├── java/ # Action classes
│ ├── resources/ # Struts + Log4j config
│ └── webapp/ # JSP views + web.xml
├── exploit/ # Exploitation tools
│ ├── Dockerfile # Exploit container
│ ├── demo_exploit.sh # Bash exploit script
│ └── exploit.py # Python exploit script
├── simulator/
│ ├── Dockerfile # Alpine + curl
│ └── simulate.sh # Test script
└── logs/ # Mounted log directory
├── nginx/
├── app/ # Defense lab logs
└── app-vulnerable/ # Vulnerable app logs
# Stop all containers
docker compose down
# Remove volumes and logs
docker compose down -v
rm -rf logs/
# Full cleanup (including images)
docker compose down --rmi all -v
Das Projekt ist wie folgt organisiert:
app/ - Abwehr-Labor-Anwendung (Struts 6.3.x, gepatcht)app-vulnerable/ - Verwundbare Anwendung (Struts 2.3.31)exploit/ - Exploitation-Tools und -Skriptenginx/ - Nginx-Reverse-Proxy-Konfiguration mit WAF-Regelnsimulator/ - Angriffsmuster-Simulatorlogs/ - Anwendungslogs (gitignoriert)# Rebuild only the vulnerable app
docker compose build app-vulnerable
docker compose up -d app-vulnerable
# Rebuild only the defense app
docker compose build app
docker compose up -d app
# Rebuild exploit container
docker compose build exploit
Haftungsausschluss: Dieses Labor dient nur zu Bildungszwecken. Verantwortungsvoll und nur in kontrollierten Umgebungen verwenden.