Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7340e4cd54 | ||
|
|
2c46b78712 | ||
|
|
e30a447662 | ||
|
|
b134cd9737 | ||
|
|
ab96939b20 | ||
|
|
28cf7080ee | ||
|
|
3023525737 | ||
|
|
a9e55469b3 | ||
|
|
6bb7758709 | ||
|
|
e08731bf37 | ||
|
|
b6dff5693c | ||
|
|
30dbefdb1b | ||
|
|
f0f5ffc140 | ||
|
|
37852b3f0b | ||
|
|
06a9034214 | ||
|
|
bcc370d70f | ||
|
|
0189330117 | ||
|
|
4dc27a4208 | ||
|
|
30d806c06c | ||
|
|
59e2594c1e | ||
|
|
df5ce2d497 | ||
|
|
0dbfcc7147 | ||
|
|
ca72e1aa2e | ||
|
|
95d70fa5a4 | ||
|
|
ef6fe18333 | ||
|
|
dcb64ac65e | ||
|
|
62d3c4282c | ||
|
|
a29a5ce4b9 | ||
|
|
4446bb6a0f | ||
|
|
122aeed6cb | ||
|
|
5e9be0a0b3 | ||
|
|
23f4e1f060 | ||
|
|
b9bc0eb079 | ||
|
|
9ba0ca98ac | ||
|
|
8933c9a669 | ||
|
|
723586029f | ||
|
|
599cf23204 | ||
|
|
b13ec8da95 | ||
|
|
6fb5c3b4ca | ||
|
|
4ee3bba0c5 | ||
|
|
b93ed45635 | ||
|
|
6818a57500 | ||
|
|
801cf7e851 | ||
|
|
069e90cf8e | ||
|
|
7787bd5f84 | ||
|
|
b5981dbe08 | ||
|
|
703db36381 | ||
|
|
31dae55b1f |
@@ -1,5 +1,5 @@
|
||||
# secrets et réponses
|
||||
answers/
|
||||
session1/answers/
|
||||
lab.conf.local
|
||||
|
||||
# artefacts générés / volumineux
|
||||
@@ -8,8 +8,8 @@ dist/
|
||||
*.qcow2
|
||||
*.vmdk
|
||||
*.ova
|
||||
content/web/site/
|
||||
content/seed/out/
|
||||
session1/content/web/site/
|
||||
session1/content/seed/out/
|
||||
run/
|
||||
logs/
|
||||
|
||||
|
||||
@@ -1,158 +1,42 @@
|
||||
# Laboratoire Norbourg — atelier d'introduction au pentest de domaine
|
||||
# Laboratoire Norbourg — ateliers
|
||||
|
||||
Laboratoire Active Directory isolé, déployé par script, pour initier des collègues au pentest de
|
||||
domaine. L'objectif : partir d'un accès anonyme et obtenir les droits de **Domain Admin**, comme
|
||||
sur une plateforme de type Hack The Box.
|
||||
Deux séances, un dépôt. Chaque dossier de séance est autonome ; `session2` ne duplique rien, il
|
||||
modifie ce que `session1` fournit.
|
||||
|
||||
> **État : fonctionnel.** Le parcours complet (site → SMB → Kerberoasting → WinRM → ACL →
|
||||
> Domain Admin) a été validé sur la plateforme `qemu`. La plateforme `proxmox` est écrite et
|
||||
> vérifiée statiquement, mais n'a pas encore tourné sur un hôte Proxmox réel.
|
||||
|
||||
## Deux plateformes, un même contenu
|
||||
|
||||
| | `qemu` | `proxmox` |
|
||||
| Dossier | État | Contenu |
|
||||
|---|---|---|
|
||||
| Cible | n'importe quel Linux avec KVM | Proxmox VE 8.x |
|
||||
| Commande | `./platforms/qemu/lab.sh` | `./platforms/proxmox/lab.sh` |
|
||||
| Configuration | `platforms/qemu/lab.conf` | `platforms/proxmox/lab.conf` |
|
||||
| Disques | qcow2 + `chattr +C` sur btrfs | stockage Proxmox (`local-lvm`, `local-zfs`…) |
|
||||
| Réseau | pont `br-lab` créé par le script | pont `vmbr10` créé à la main dans l'interface |
|
||||
| Réinitialisation | base + couche jetable (~2 s) | gabarit + clone |
|
||||
| Accès participants | route vers `10.10.10.0/24` | VM routeur WireGuard |
|
||||
| [`session1/`](session1/README.md) | **fonctionnel, validé** | laboratoire AD complet : deux plateformes, documentation, solution |
|
||||
| [`session2/`](session2/README.md) | **conception seulement** | vol de matériel d'authentification (LSASS, mimikatz) — rien n'est implémenté |
|
||||
|
||||
Le contenu commun — scripts PowerShell, site archivé, documentation, solution — vit dans
|
||||
`content/` et `docs/`. Les deux plateformes ne diffèrent que par la couche de virtualisation.
|
||||
## Session 1 — le laboratoire
|
||||
|
||||
## Topologie
|
||||
|
||||
```
|
||||
participant (Kali)
|
||||
│ route 10.10.10.0/24 via 10.10.10.1 (ou tunnel WireGuard)
|
||||
▼
|
||||
hôte 10.10.10.1 / 10.10.10.230 pont isolé
|
||||
├── DC01 10.10.10.10 contrôleur de domaine, DNS
|
||||
├── FS01 10.10.10.20 serveur de fichiers, site 2002, partage Public
|
||||
└── WS01 10.10.10.31 poste de travail
|
||||
```
|
||||
|
||||
## Prérequis
|
||||
|
||||
- Hôte Linux avec KVM, 16 Go de RAM et ~80 Go libres, **ou** un hôte Proxmox VE 8.x.
|
||||
- Un accès `sudo` une seule fois sur la plateforme `qemu` (pont et pare-feu).
|
||||
- Une machine Kali sur le même réseau local, ou un tunnel WireGuard.
|
||||
|
||||
---
|
||||
|
||||
## Démarrage — plateforme `qemu` (Linux générique)
|
||||
Le contenu de référence : domaine `norbourg.lab`, site archivé de 2002, chemin d'élévation par
|
||||
délégation ACL, deux plateformes (`qemu` et `proxmox`).
|
||||
|
||||
```bash
|
||||
cd platforms/qemu
|
||||
./lab.sh check # valide hôte, stockage, réseau, configuration
|
||||
./lab.sh init # arborescence + chattr +C
|
||||
sudo ./setup-network.sh # pont br-lab et isolation — seule étape root
|
||||
./lab.sh isos # télécharge 5,6 Go d'images Windows
|
||||
./lab.sh build # installe les 3 VM sans intervention (~20 min)
|
||||
./lab.sh provision # domaine, comptes, ACL, drapeaux (~15 min)
|
||||
./lab.sh web --sync # publie le site 2002 sur FS01
|
||||
./lab.sh snapshot # fige l'état propre
|
||||
cd session1/platforms/qemu
|
||||
./lab.sh check
|
||||
./lab.sh doctor
|
||||
```
|
||||
|
||||
## Démarrage — plateforme `proxmox`
|
||||
Documentation, prérequis et solution : [`session1/docs/`](session1/docs/), solution complète dans
|
||||
`session1/answers/` (non versionnée).
|
||||
|
||||
1. Remplir `platforms/proxmox/lab.conf` : stockages, pont, adresse de l'hôte.
|
||||
2. Créer le pont dans l'interface Proxmox : *Datacenter > nœud > Network > Create > Linux
|
||||
Bridge*, nom `vmbr10`, **aucun port**, IPv4 `10.10.10.1/24`, pas de passerelle.
|
||||
3. Puis :
|
||||
## Session 2 — la suite
|
||||
|
||||
Deuxième séance, même laboratoire, autre compétence : voler le matériel d'authentification d'un
|
||||
administrateur dans LSASS, puis le réutiliser contre le contrôleur de domaine.
|
||||
|
||||
Rien n'est codé. Le dossier contient la conception : le plant nécessaire, la chaîne, les
|
||||
détections à ajouter, les risques et l'ordre de travail.
|
||||
|
||||
## Archives de déploiement
|
||||
|
||||
Pour un hôte sans accès au serveur git, chaque plateforme de la session 1 se met en archive :
|
||||
|
||||
```bash
|
||||
cd platforms/proxmox
|
||||
./lab.sh check # refuse de continuer si la config ne correspond pas à l'hôte
|
||||
./lab.sh init
|
||||
./lab.sh isos
|
||||
./lab.sh build
|
||||
./lab.sh provision
|
||||
./lab.sh web --sync
|
||||
./lab.sh snapshot # convertit les VM en gabarits
|
||||
./build-bundle.sh proxmox # ou qemu, ou sans argument pour les deux
|
||||
# produit dist/norbourg-<plateforme>.tar.gz
|
||||
```
|
||||
|
||||
Sans accès au serveur git sur l'hôte Proxmox, construisez une archive autonome :
|
||||
|
||||
```bash
|
||||
./build-bundle.sh proxmox # produit dist/norbourg-proxmox.tar.gz
|
||||
scp dist/norbourg-proxmox.tar.gz root@pve:/root/
|
||||
```
|
||||
|
||||
## Machine d'attaque (Kali, optionnel)
|
||||
|
||||
La plateforme `qemu` peut installer l'image QEMU officielle de Kali, avec tous les outils de
|
||||
l'atelier :
|
||||
|
||||
```bash
|
||||
./lab.sh kali install # télécharge ~4 Go, extrait, prépare une couche jetable
|
||||
./lab.sh kali up # démarre (VNC 127.0.0.1:5909, SSH 127.0.0.1:2222)
|
||||
./lab.sh kali reset # repart de l'image propre
|
||||
./lab.sh kali down
|
||||
```
|
||||
|
||||
Identifiants par défaut : `kali` / `kali`. La VM a deux cartes : le pont du laboratoire
|
||||
(adresse fournie par le DHCP de DC01) et un réseau utilisateur qui permet `apt` sans ouvrir de
|
||||
passage vers le réseau du bureau.
|
||||
|
||||
## Commandes
|
||||
|
||||
| Commande | Effet |
|
||||
|---|---|
|
||||
| `check` | préflight ; refuse si le stockage ou la config sont inadaptés |
|
||||
| `init` | arborescence, désactivation du CoW |
|
||||
| `isos` | télécharge les images d'évaluation Microsoft |
|
||||
| `seeds` | génère les fichiers de réponse et les ISO d'amorçage |
|
||||
| `build` | disques + installation sans intervention |
|
||||
| `provision [--role N]` | domaine, comptes, ACL, partage, drapeaux |
|
||||
| `web [--sync]` | assemble le site et le pousse sur FS01 |
|
||||
| `snapshot [--update]` | fige une base ; `--update` y intègre les changements |
|
||||
| `up` / `down` | démarre (DC d'abord) / arrête |
|
||||
| `reset` | repart de la base |
|
||||
| `status` / `doctor` | tableau des VM / bilan de santé |
|
||||
| `vnc <vm>` | console graphique (plateforme qemu) |
|
||||
| `answers` | affiche la solution de l'instructeur |
|
||||
| `peers` | configs WireGuard (plateforme proxmox) |
|
||||
|
||||
## Structure du dépôt
|
||||
|
||||
| Chemin | Rôle |
|
||||
|---|---|
|
||||
| `platforms/qemu/` | point d'entrée et configuration pour un Linux générique |
|
||||
| `platforms/proxmox/` | point d'entrée et configuration pour Proxmox VE |
|
||||
| `content/lib/` | commandes communes, préflight, orchestration |
|
||||
| `content/windows/` | scripts PowerShell par machine |
|
||||
| `content/seed/` | fichier de réponse et charge utile des ISO d'amorçage |
|
||||
| `content/site-src/` | site Norbourg 2002 : miroir et images retouchées |
|
||||
| `content/web/` | site assemblé et fichiers pièges |
|
||||
| `content/scripts/` | assistants partagés (WinRM, préparation du site, liste de mots) |
|
||||
| `docs/` | documentation de l'atelier, en français |
|
||||
| `answers/` | solution complète — **ignoré par git** |
|
||||
| `build-bundle.sh` | fabrique une archive autonome par plateforme |
|
||||
|
||||
## Isolation
|
||||
|
||||
Rien du laboratoire ne doit joindre le réseau de bureau ni Internet :
|
||||
|
||||
- le pont du laboratoire n'a aucun port vers l'extérieur ;
|
||||
- seul le sens participant → laboratoire est autorisé, sur les ports nécessaires
|
||||
(DNS, Kerberos, LDAP, SMB, WinRM, HTTP) ;
|
||||
- le sens laboratoire → bureau est rejeté.
|
||||
|
||||
Sur `qemu`, c'est le pare-feu de l'hôte qui l'applique ; sur `proxmox`, le pont sans port suffit,
|
||||
et le routeur WireGuard ne fait que router.
|
||||
|
||||
## Contenu archivé
|
||||
|
||||
`content/site-src/` contient une capture du site public de Norbourg tel qu'il existait en 2002,
|
||||
provenant de la Wayback Machine. Il sert de décor au laboratoire et de point d'entrée pour les
|
||||
participants. Usage strictement interne et pédagogique.
|
||||
|
||||
## Avertissement
|
||||
|
||||
Laboratoire jetable. Les images Windows sont des versions d'évaluation Microsoft (180 jours pour
|
||||
Server, 90 jours pour Windows 11) : à reconstruire périodiquement, jamais à exposer, jamais en
|
||||
production. Les vulnérabilités sont volontaires.
|
||||
L'archive se décompresse à plat : `norbourg-qemu/platforms/qemu/lab.sh`.
|
||||
|
||||
@@ -13,6 +13,7 @@ set -euo pipefail
|
||||
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)
|
||||
TARGET=${1:-all}
|
||||
OUT=${2:-$ROOT/dist}
|
||||
SRC="$ROOT/session1"
|
||||
|
||||
info() { printf '[*] %s\n' "$*"; }
|
||||
ok() { printf '[ok] %s\n' "$*"; }
|
||||
@@ -22,14 +23,14 @@ build() {
|
||||
local stage="$OUT/norbourg-$platform"
|
||||
local archive="$OUT/norbourg-$platform.tar.gz"
|
||||
|
||||
[[ -d $ROOT/platforms/$platform ]] || { echo "no such platform: $platform" >&2; return 1; }
|
||||
[[ -d $SRC/platforms/$platform ]] || { echo "no such platform in session1: $platform" >&2; return 1; }
|
||||
|
||||
rm -rf "$stage"
|
||||
mkdir -p "$stage"
|
||||
|
||||
# Shared content + one platform + docs + answers. Generated and transient
|
||||
# paths are excluded: they are rebuilt by the host's own commands.
|
||||
tar -C "$ROOT" -cf - \
|
||||
tar -C "$SRC" -cf - \
|
||||
--exclude='.git' \
|
||||
--exclude='__pycache__' \
|
||||
--exclude='*.pyc' \
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
# shellcheck shell=bash
|
||||
# cmd_doctor — end-to-end health check of the running laboratory.
|
||||
|
||||
_d_ok() { ok "$*"; }
|
||||
_d_warn() { warn "$*"; DOCTOR_WARNS=$(( DOCTOR_WARNS + 1 )); }
|
||||
_d_fail() { fail "$*"; DOCTOR_FAILS=$(( DOCTOR_FAILS + 1 )); }
|
||||
|
||||
cmd_doctor() {
|
||||
DOCTOR_FAILS=0
|
||||
DOCTOR_WARNS=0
|
||||
local i name ip
|
||||
|
||||
step "host"
|
||||
if ip link show "$LAB_BRIDGE" >/dev/null 2>&1; then
|
||||
_d_ok "bridge ${LAB_BRIDGE} present"
|
||||
else
|
||||
_d_fail "bridge ${LAB_BRIDGE} missing — run sudo ./platforms/qemu/setup-network.sh"
|
||||
fi
|
||||
|
||||
step "machines"
|
||||
for i in "${!VM_NAMES[@]}"; do
|
||||
name=${VM_NAMES[$i]}
|
||||
ip=${VM_IPS[$i]}
|
||||
|
||||
if ! backend_running "$name"; then
|
||||
_d_fail "$name is not running — ./lab.sh up"
|
||||
continue
|
||||
fi
|
||||
|
||||
if tcp_open "$ip" 445; then
|
||||
_d_ok "$(printf '%-6s %-14s smb up' "$name" "$ip")"
|
||||
else
|
||||
_d_warn "$(printf '%-6s %-14s smb not answering' "$name" "$ip")"
|
||||
fi
|
||||
|
||||
if [[ $name == dc01 || $name == ws01 || $name == fs01 ]]; then
|
||||
if tcp_open "$ip" 5985; then
|
||||
_d_ok "$(printf '%-6s %-14s winrm up' "$name" "$ip")"
|
||||
else
|
||||
_d_warn "$(printf '%-6s %-14s winrm not answering' "$name" "$ip")"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
step "domain"
|
||||
if have_cmd dig; then
|
||||
local www
|
||||
www=$(dig +short +time=2 +tries=1 "@$LAB_DC_IP" www.norbourg.lab 2>/dev/null | head -1)
|
||||
if [[ $www == 10.10.10.20 ]]; then
|
||||
_d_ok "dns: www.norbourg.lab -> $www"
|
||||
else
|
||||
_d_fail "dns: www.norbourg.lab did not resolve via ${LAB_DC_IP} (got '${www:-nothing}')"
|
||||
fi
|
||||
local srv
|
||||
srv=$(dig +short +time=2 +tries=1 "@$LAB_DC_IP" SRV _ldap._tcp.dc._msdcs.norbourg.lab 2>/dev/null | head -1)
|
||||
if [[ -n $srv ]]; then
|
||||
_d_ok "dns: ldap SRV record present"
|
||||
else
|
||||
_d_fail "dns: ldap SRV record missing — AD discovery would fail"
|
||||
fi
|
||||
else
|
||||
_d_warn "dig not installed, DNS checks skipped"
|
||||
fi
|
||||
|
||||
step "web"
|
||||
local code
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 "http://10.10.10.20/" 2>/dev/null || true)
|
||||
if [[ $code == 200 ]]; then
|
||||
_d_ok "site answers on 10.10.10.20"
|
||||
else
|
||||
_d_fail "site not answering (${code:-timeout}) — ./lab.sh web --sync"
|
||||
fi
|
||||
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 "http://10.10.10.20/public/IT-inventaire.txt" 2>/dev/null || true)
|
||||
if [[ $code == 200 ]]; then
|
||||
_d_ok "entry point reachable: /public/IT-inventaire.txt"
|
||||
else
|
||||
_d_fail "entry point missing (${code:-timeout})"
|
||||
fi
|
||||
|
||||
step "share"
|
||||
if have_cmd smbclient; then
|
||||
if smbclient //10.10.10.20/Public -U 'NORBOURG\helpdesk1%Welcome2024!' -c 'ls' 2>/dev/null | grep -q 'IT-inventaire'; then
|
||||
_d_ok "Public share reachable with the leaked credential"
|
||||
else
|
||||
_d_warn "Public share not readable as helpdesk1 (domain channel or DNS?)"
|
||||
fi
|
||||
else
|
||||
_d_warn "smbclient not installed, share check skipped"
|
||||
fi
|
||||
|
||||
printf '\n'
|
||||
if (( DOCTOR_FAILS )); then
|
||||
fail "${DOCTOR_FAILS} problem(s), ${DOCTOR_WARNS} warning(s)"
|
||||
return 1
|
||||
fi
|
||||
ok "laboratory healthy · ${DOCTOR_WARNS} warning(s)"
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
# Norbourg lab — first-boot bootstrap, runs once from the seed ISO.
|
||||
# The unattend file creates the account and triggers this; everything that
|
||||
# touches the network happens here because unattend TCPIP settings fail
|
||||
# silently when the adapter name does not match.
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$base = 'C:\norbourg'
|
||||
New-Item -ItemType Directory -Force -Path $base | Out-Null
|
||||
Start-Transcript -Path "$base\bootstrap.log" -Append | Out-Null
|
||||
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
. (Join-Path $here 'config.ps1')
|
||||
|
||||
Write-Host "bootstrap: host=$($Config.Hostname) role=$($Config.Role) ip=$($Config.IP)"
|
||||
|
||||
# ------------------------------------------------------------------ network
|
||||
$nic = Get-NetAdapter |
|
||||
Where-Object { $_.Status -eq 'Up' -and $_.InterfaceDescription -notmatch 'Loopback' } |
|
||||
Select-Object -First 1
|
||||
|
||||
if (-not $nic) {
|
||||
Write-Host 'bootstrap: no up adapter, network step skipped'
|
||||
} else {
|
||||
Remove-NetIPAddress -InterfaceIndex $nic.ifIndex -Confirm:$false -ErrorAction SilentlyContinue
|
||||
Remove-NetRoute -InterfaceIndex $nic.ifIndex -Confirm:$false -ErrorAction SilentlyContinue
|
||||
|
||||
New-NetIPAddress -InterfaceIndex $nic.ifIndex `
|
||||
-IPAddress $Config.IP -PrefixLength $Config.Prefix `
|
||||
-DefaultGateway $Config.Gateway | Out-Null
|
||||
|
||||
Set-DnsClientServerAddress -InterfaceIndex $nic.ifIndex -ServerAddresses $Config.DNS
|
||||
Set-NetConnectionProfile -InterfaceIndex $nic.ifIndex -NetworkCategory Private -ErrorAction SilentlyContinue
|
||||
|
||||
# The IP change re-triggers the "make this PC discoverable" flyout.
|
||||
New-Item -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Network' -Force | Out-Null
|
||||
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Network' `
|
||||
-Name NewNetworkWindowOff -Value 1 -Type DWord
|
||||
|
||||
Write-Host "bootstrap: $($nic.Name) -> $($Config.IP)/$($Config.Prefix)"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------ WinRM
|
||||
# The host provisions over WinRM; no guest agent needed for that.
|
||||
Enable-PSRemoting -SkipNetworkProfileCheck -Force | Out-Null
|
||||
Set-NetFirewallRule -DisplayGroup 'Windows Remote Management' -Enabled True -Profile Any -ErrorAction SilentlyContinue
|
||||
|
||||
# SMB: the eval image leaves File and Printer Sharing disabled, which makes the
|
||||
# workstation invisible to a normal SMB scan.
|
||||
Enable-NetFirewallRule -DisplayGroup 'File and Printer Sharing' -ErrorAction SilentlyContinue
|
||||
|
||||
# RDP: useful for the instructor when a step misbehaves.
|
||||
Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\Terminal Server' `
|
||||
-Name fDenyTSConnections -Value 0
|
||||
Enable-NetFirewallRule -DisplayGroup 'Remote Desktop' -ErrorAction SilentlyContinue
|
||||
|
||||
# ------------------------------------------------------------------ marker
|
||||
"$env:COMPUTERNAME|$($Config.Role)|$($Config.IP)|$((Get-Date).ToString('s'))" |
|
||||
Set-Content -Path "$base\stamp.txt" -Encoding ascii
|
||||
|
||||
# ------------------------------------------------------------------ role
|
||||
$role = Join-Path $here "roles\$($Config.Role).ps1"
|
||||
if (Test-Path $role) {
|
||||
Write-Host "bootstrap: running role $($Config.Role)"
|
||||
& $role
|
||||
} else {
|
||||
Write-Host "bootstrap: no role script for '$($Config.Role)' yet (phase 5)"
|
||||
}
|
||||
|
||||
Write-Host 'bootstrap: done'
|
||||
Stop-Transcript | Out-Null
|
||||
@@ -1,100 +0,0 @@
|
||||
# Guide du participant
|
||||
|
||||
## Le contexte
|
||||
|
||||
Norbourg Services Financiers a fermé ses portes en 2005. Le serveur de fichiers, lui, n'a jamais
|
||||
été mis au rancart : il tourne encore, avec son site Web de 2002, dans un coin du réseau. La
|
||||
direction veut savoir ce qu'un attaquant pourrait y faire avant de confier la migration à un
|
||||
sous-traitant.
|
||||
|
||||
Vous êtes ce sous-traitant. Votre mandat tient en une phrase : **obtenir les droits de Domain
|
||||
Admin**.
|
||||
|
||||
## Votre objectif
|
||||
|
||||
Deux drapeaux à rapporter :
|
||||
|
||||
| Drapeau | Où | Ce qu'il prouve |
|
||||
|---|---|---|
|
||||
| `user.txt` | sur un poste de travail | vous avez compromis une machine |
|
||||
| `root.txt` | sur le contrôleur de domaine | vous contrôlez le domaine |
|
||||
|
||||
Un drapeau a le format `NORBOURG{...}`. Notez-le et gardez-le pour le débriefing.
|
||||
|
||||
## Règles d'engagement
|
||||
|
||||
- **Seulement `10.10.10.0/24`.** Ne touchez pas à `10.10.10.230` (l'hôte du laboratoire) ni à
|
||||
quoi que ce soit sur `192.168.10.0/24`.
|
||||
- **Pas de déni de service.** Pas de balayage agressif, pas de saturation, pas de `--flood`.
|
||||
- **Pas de destruction.** Ne supprimez pas de comptes, ne réinitialisez pas de mots de passe dont
|
||||
vous n'avez pas besoin, ne chiffrez rien.
|
||||
- **Tout reste dans le laboratoire.** Aucune donnée ne sort du réseau.
|
||||
- Si vous cassez quelque chose, dites-le : c'est un laboratoire, ça se répare, mais il faut le
|
||||
savoir pour les autres.
|
||||
|
||||
## Méthodologie suggérée
|
||||
|
||||
1. **Reconnaissance** — quelles machines répondent, quels services écoutent.
|
||||
2. **Énumération** — qu'est-ce que ces services racontent : partages, utilisateurs, pages Web.
|
||||
3. **Point d'entrée** — trouver un premier identifiant valide.
|
||||
4. **Élévation** — transformer un compte ordinaire en compte puissant.
|
||||
5. **Déplacement latéral** — passer d'une machine à l'autre avec les droits obtenus.
|
||||
6. **Compromission du domaine** — la cible finale.
|
||||
|
||||
Ne sautez pas d'étape. La plupart des impasses viennent d'une énumération bâclée, pas d'un
|
||||
manque d'outil.
|
||||
|
||||
## Aide-mémoire
|
||||
|
||||
```bash
|
||||
# découverte
|
||||
nmap -sn 10.10.10.0/24
|
||||
nmap -sV -p- 10.10.10.10
|
||||
|
||||
# SMB / AD
|
||||
netexec smb 10.10.10.0/24
|
||||
netexec smb 10.10.10.10 -u '<user>' -p '<pass>' --shares
|
||||
netexec smb 10.10.10.10 -u '<user>' -p '<pass>' --users
|
||||
|
||||
# Kerberos
|
||||
impacket-GetUserSPNs norbourg.lab/<user>:<pass> -dc-ip 10.10.10.10 -request
|
||||
|
||||
# cassage
|
||||
hashcat -m 13100 hash.txt /opt/norbourg/wordlists/norbourg.txt
|
||||
hashcat -m 18200 hash.txt /opt/norbourg/wordlists/norbourg.txt
|
||||
|
||||
# mouvement latéral
|
||||
netexec winrm 10.10.10.31 -u '<user>' -p '<pass>'
|
||||
evil-winrm -i 10.10.10.31 -u '<user>' -p '<pass>'
|
||||
|
||||
# cartographie du domaine
|
||||
bloodhound-python -d norbourg.lab -u '<user>' -p '<pass>' -ns 10.10.10.10 -c all
|
||||
```
|
||||
|
||||
Les mots de passe du laboratoire se cassent en quelques secondes avec
|
||||
`/opt/norbourg/wordlists/norbourg.txt`. Inutile de lancer `rockyou.txt` complet : vous perdriez
|
||||
vingt minutes pour rien.
|
||||
|
||||
## Rappel terminal
|
||||
|
||||
Si vous n'êtes pas à l'aise en ligne de commande :
|
||||
|
||||
| Commande | Effet |
|
||||
|---|---|
|
||||
| `ls` | lister le dossier courant |
|
||||
| `cd <dossier>` | entrer dans un dossier |
|
||||
| `cat <fichier>` | afficher un fichier |
|
||||
| `grep mot fichier` | chercher un mot |
|
||||
| `commande \| grep mot` | filtrer la sortie d'une commande |
|
||||
| `commande > fichier` | écrire la sortie dans un fichier |
|
||||
| `Ctrl-C` | interrompre |
|
||||
| `man <commande>` | documentation |
|
||||
|
||||
Une commande qui « ne fait rien » affiche souvent son erreur sur la sortie d'erreur : lisez-la.
|
||||
|
||||
## Si vous êtes bloqué
|
||||
|
||||
- Relisez la sortie de vos commandes : les outils d'énumération disent souvent quoi faire ensuite.
|
||||
- Vérifiez votre configuration réseau (voir `prerequis.md`) : un `NXDOMAIN` n'est pas un serveur
|
||||
mort, c'est un DNS mal pointé.
|
||||
- Demandez un indice à l'instructeur : il en existe trois niveaux, du plus vague au plus direct.
|
||||
@@ -1,94 +0,0 @@
|
||||
# Prérequis — participants
|
||||
|
||||
À faire **avant** l'atelier. Comptez quinze minutes, dont la majeure partie consiste à
|
||||
attendre que votre machine virtuelle démarre.
|
||||
|
||||
## Ce qu'il vous faut
|
||||
|
||||
- Une machine Kali Linux, en VM ou sur votre poste, branchée sur le même réseau que l'hôte du
|
||||
laboratoire (`192.168.10.0/24`).
|
||||
- Les droits `sudo` dans ce Kali.
|
||||
- Rien d'autre : l'image fournie contient déjà tous les outils de l'atelier
|
||||
(`netexec`, Impacket, BloodHound, hashcat, rockyou).
|
||||
|
||||
> Le laboratoire est isolé : une fois connecté, la résolution de noms vers Internet cesse de
|
||||
> fonctionner. C'est normal et voulu. La section 5 explique comment revenir en arrière.
|
||||
|
||||
## 1. Route vers le laboratoire
|
||||
|
||||
```bash
|
||||
sudo ip route add 10.10.10.0/24 via 192.168.10.230
|
||||
```
|
||||
|
||||
Pour que la route survive à un redémarrage, utilisez plutôt NetworkManager :
|
||||
|
||||
```bash
|
||||
sudo nmcli con mod "<votre-connexion>" +ipv4.routes "10.10.10.0/24 192.168.10.230"
|
||||
sudo nmcli con up "<votre-connexion>"
|
||||
```
|
||||
|
||||
Remplacez `<votre-connexion>` par le nom affiché par `nmcli con show` (souvent `Wired
|
||||
connection 1` ou `eth0`).
|
||||
|
||||
## 2. DNS vers le contrôleur de domaine
|
||||
|
||||
```bash
|
||||
sudo nmcli con mod "<votre-connexion>" ipv4.dns 10.10.10.10 ipv4.ignore-auto-dns yes
|
||||
sudo nmcli con up "<votre-connexion>"
|
||||
```
|
||||
|
||||
**Pourquoi le DNS et non `/etc/hosts` ?** Active Directory se découvre par des
|
||||
enregistrements `SRV` (`_ldap._tcp.dc._msdcs.norbourg.lab`). Un fichier `hosts` ne fournit que
|
||||
des noms de machines : la découverte du domaine, `netexec smb norbourg.lab` et les requêtes
|
||||
Kerberos par nom échoueront. Le fichier `hosts` est un pis-aller, pas une solution.
|
||||
|
||||
## 3. Vérification
|
||||
|
||||
Les quatre commandes doivent répondre :
|
||||
|
||||
```bash
|
||||
ping -c 2 10.10.10.10
|
||||
nslookup www.norbourg.lab
|
||||
nslookup -type=SRV _ldap._tcp.dc._msdcs.norbourg.lab
|
||||
nmap -Pn -p 88,389,445 10.10.10.10
|
||||
```
|
||||
|
||||
Résultats attendus :
|
||||
|
||||
| Commande | Attendu |
|
||||
|---|---|
|
||||
| `ping` | réponses de `10.10.10.10` |
|
||||
| `nslookup www` | `10.10.10.20` |
|
||||
| `nslookup -type=SRV` | un enregistrement pointant vers `dc01.norbourg.lab` |
|
||||
| `nmap` | ports `88`, `389` et `445` ouverts |
|
||||
|
||||
## 4. Si quelque chose ne répond pas
|
||||
|
||||
| Symptôme | Cause probable | Correctif |
|
||||
|---|---|---|
|
||||
| `ping` sans réponse | route absente | refaire l'étape 1 |
|
||||
| `ping` OK, `nslookup` en `NXDOMAIN` | DNS encore chez le routeur du bureau | refaire l'étape 2 |
|
||||
| `nslookup` OK, `nmap` en `filtered` | pare-feu de l'hôte | aviser l'instructeur |
|
||||
| `ping` OK mais tout le reste échoue | vous êtes sur le Wi-Fi invité, pas sur le réseau du labo | changer de réseau |
|
||||
|
||||
## 5. Revenir en arrière
|
||||
|
||||
Après l'atelier, pour retrouver Internet :
|
||||
|
||||
```bash
|
||||
sudo ip route del 10.10.10.0/24 via 192.168.10.230
|
||||
sudo nmcli con mod "<votre-connexion>" ipv4.ignore-auto-dns no ipv4.dns ""
|
||||
sudo nmcli con up "<votre-connexion>"
|
||||
```
|
||||
|
||||
## Adresses du laboratoire
|
||||
|
||||
| Machine | Adresse | Rôle |
|
||||
|---|---|---|
|
||||
| Passerelle | `10.10.10.230` | hôte du laboratoire, ne pas attaquer |
|
||||
| `dc01` | `10.10.10.10` | contrôleur de domaine, DNS |
|
||||
| `fs01` | `10.10.10.20` | serveur de fichiers, site archivé |
|
||||
| `ws01` | `10.10.10.31` | poste de travail |
|
||||
|
||||
Les adresses `10.10.10.1` à `10.10.10.9` et `10.10.10.200` et plus ne font pas partie du
|
||||
laboratoire.
|
||||
@@ -1,392 +0,0 @@
|
||||
# shellcheck shell=bash
|
||||
# Proxmox VE backend.
|
||||
#
|
||||
# Hardware model mirrors the QEMU platform: q35 + SATA + e1000, so the same
|
||||
# unattended file and the same role scripts work unchanged. Provisioning talks
|
||||
# to the QEMU guest agent (`qm guest exec`), so the Proxmox host needs no
|
||||
# Python packages beyond its own.
|
||||
|
||||
# ------------------------------------------------------------------ helpers
|
||||
pve_vmid() {
|
||||
local i
|
||||
i=$(vm_index "$1") || return 1
|
||||
printf '%s' $(( PVE_VMID_BASE + i ))
|
||||
}
|
||||
|
||||
pve_template_vmid() {
|
||||
local i
|
||||
i=$(vm_index "$1") || return 1
|
||||
printf '%s' $(( PVE_VMID_BASE + 100 + i ))
|
||||
}
|
||||
|
||||
pve_exists() { qm status "$1" >/dev/null 2>&1; }
|
||||
pve_is_template() { qm config "$1" 2>/dev/null | grep -qx 'template: 1'; }
|
||||
pve_running() { qm status "$1" 2>/dev/null | grep -q 'status: running'; }
|
||||
pve_ip() { local i; i=$(vm_index "$1"); printf '%s' "${VM_IPS[$i]}"; }
|
||||
|
||||
# ------------------------------------------------------------------ preflight
|
||||
# Which storages advertise iso content. `pvesm status --content` is not
|
||||
# available on every version, so fall back to parsing storage.cfg.
|
||||
pve_iso_storages() {
|
||||
local out
|
||||
out=$(pvesm status --content iso 2>/dev/null | awk 'NR>1{print $1}' | tr '\n' ' ')
|
||||
if [[ -z ${out// /} && -r /etc/pve/storage.cfg ]]; then
|
||||
out=$(awk '/^[a-z]+: /{name=$2} /^[[:space:]]*content[[:space:]]/ && /iso/ {print name}' \
|
||||
/etc/pve/storage.cfg | tr '\n' ' ')
|
||||
fi
|
||||
printf '%s' "$out"
|
||||
}
|
||||
|
||||
backend_check() {
|
||||
if ! command -v qm >/dev/null 2>&1; then
|
||||
_c_fail "qm not found — this script must run on a Proxmox VE host"
|
||||
return
|
||||
fi
|
||||
_c_ok "qm present ($(pveversion 2>/dev/null | cut -d/ -f1-2))"
|
||||
|
||||
command -v pvesm >/dev/null 2>&1 && _c_ok "pvesm present" || _c_fail "pvesm missing"
|
||||
|
||||
# storages
|
||||
local iso_content
|
||||
if pvesm status 2>/dev/null | awk 'NR>1{print $1}' | grep -qx "$PVE_STORAGE_DISKS"; then
|
||||
_c_ok "disk storage ${PVE_STORAGE_DISKS} present"
|
||||
else
|
||||
_c_fail "disk storage ${PVE_STORAGE_DISKS} not found (run pvesm status)"
|
||||
fi
|
||||
|
||||
iso_content=$(pve_iso_storages)
|
||||
if [[ " $iso_content " == *" ${PVE_STORAGE_ISO} "* ]]; then
|
||||
_c_ok "iso storage ${PVE_STORAGE_ISO} present"
|
||||
else
|
||||
_c_fail "storage ${PVE_STORAGE_ISO} has no iso content (available: ${iso_content:-none})"
|
||||
fi
|
||||
|
||||
if [[ -d $PVE_ISO_DIR && -w $PVE_ISO_DIR ]]; then
|
||||
_c_ok "iso directory ${PVE_ISO_DIR} writable"
|
||||
else
|
||||
_c_fail "iso directory ${PVE_ISO_DIR} missing or not writable"
|
||||
fi
|
||||
|
||||
# isolated bridge
|
||||
if [[ -d /sys/class/net/$PVE_BRIDGE ]]; then
|
||||
if ip -4 -o addr show dev "$PVE_BRIDGE" 2>/dev/null | grep -q "inet ${LAB_HOST_IP}/"; then
|
||||
_c_ok "bridge ${PVE_BRIDGE} has ${LAB_HOST_IP}"
|
||||
else
|
||||
_c_fail "bridge ${PVE_BRIDGE} exists but does not carry ${LAB_HOST_IP}"
|
||||
fi
|
||||
else
|
||||
_c_fail "bridge ${PVE_BRIDGE} missing — create it in the GUI (see lab.conf)"
|
||||
fi
|
||||
|
||||
# guest agent is what provisioning talks to; it cannot be probed before boot
|
||||
_c_ok "provisioning over qm guest exec (agent installed by bootstrap)"
|
||||
|
||||
[[ -f $WINDOWS_ISO ]] && _c_ok "Windows ISO present" \
|
||||
|| _c_warn "Windows ISO missing: run ./lab.sh isos"
|
||||
|
||||
if command -v genisoimage >/dev/null 2>&1 || command -v xorriso >/dev/null 2>&1; then
|
||||
_c_ok "ISO tooling present"
|
||||
else
|
||||
_c_fail "genisoimage or xorriso required to build seed ISOs"
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------ lifecycle
|
||||
backend_running() {
|
||||
local vmid
|
||||
vmid=$(pve_vmid "$1") || return 1
|
||||
pve_running "$vmid"
|
||||
}
|
||||
|
||||
backend_create_disk() {
|
||||
local name=$1 dry=${2:-0}
|
||||
local i vmid ram disk vcpu seed win mac
|
||||
|
||||
i=$(vm_index "$name") || die "unknown vm: $name"
|
||||
vmid=$(pve_vmid "$name")
|
||||
ram=${VM_RAM[$i]}; disk=${VM_DISK[$i]}; vcpu=${VM_VCPU[$i]}
|
||||
seed="$SEED_DIR/${name}-seed.iso"
|
||||
win=$WINDOWS_ISO
|
||||
mac=$(qemu_mac_for "${VM_IPS[$i]}")
|
||||
|
||||
if pve_exists "$vmid"; then
|
||||
ok "$(printf '%-6s vm %s already exists' "$name" "$vmid")"
|
||||
return 0
|
||||
fi
|
||||
[[ -f $seed ]] || (( dry )) || die "missing seed ISO for $name (run ./lab.sh seeds)"
|
||||
[[ -f $win ]] || (( dry )) || die "missing Windows ISO: $win (run ./lab.sh isos)"
|
||||
|
||||
local args=(
|
||||
"$vmid"
|
||||
--name "norbourg-$name"
|
||||
--memory "$ram" --cores "$vcpu" --sockets 1
|
||||
--machine "$PVE_MACHINE" --bios "$PVE_BIOS" --ostype "$PVE_OSTYPE" --cpu "$PVE_CPU"
|
||||
--net0 "${PVE_NET_MODEL},bridge=${PVE_BRIDGE},macaddr=${mac}"
|
||||
--sata0 "${PVE_STORAGE_DISKS}:${disk}"
|
||||
--ide2 "${PVE_STORAGE_ISO}:iso/$(basename "$win"),media=cdrom"
|
||||
--ide0 "${PVE_STORAGE_ISO}:iso/$(basename "$seed"),media=cdrom"
|
||||
--boot "order=ide2;ide0"
|
||||
--onboot 0
|
||||
)
|
||||
(( PVE_AGENT )) && args+=( --agent enabled=1 )
|
||||
|
||||
if (( dry )); then
|
||||
info " + qm create ${args[*]}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
qm create "${args[@]}" || { fail "qm create failed for $name"; return 1; }
|
||||
ok "$(printf '%-6s vm %s created (%sG on %s)' "$name" "$vmid" "$disk" "$PVE_STORAGE_DISKS")"
|
||||
}
|
||||
|
||||
backend_launch() {
|
||||
local name=$1 mode=${2:-run} dry=${3:-0}
|
||||
local vmid
|
||||
vmid=$(pve_vmid "$name")
|
||||
|
||||
if (( dry )); then
|
||||
info " + qm start $vmid"
|
||||
return 0
|
||||
fi
|
||||
pve_running "$vmid" && { info " $name already running"; return 0; }
|
||||
|
||||
qm start "$vmid" >/dev/null || { fail "qm start failed for $name"; return 1; }
|
||||
ok "$(printf '%-6s started (vm %s)' "$name" "$vmid")"
|
||||
}
|
||||
|
||||
backend_stop() {
|
||||
local name=$1 vmid
|
||||
vmid=$(pve_vmid "$name")
|
||||
|
||||
pve_running "$vmid" || { info " $name already stopped"; return 0; }
|
||||
|
||||
qm shutdown "$vmid" --timeout 90 >/dev/null 2>&1 || true
|
||||
if pve_running "$vmid"; then
|
||||
warn "$name did not shut down cleanly, forcing stop"
|
||||
qm stop "$vmid" >/dev/null 2>&1 || true
|
||||
sleep 2
|
||||
fi
|
||||
ok "$name stopped"
|
||||
}
|
||||
|
||||
backend_snapshot() {
|
||||
local name=$1 vmid tpl
|
||||
vmid=$(pve_vmid "$name")
|
||||
tpl=$(pve_template_vmid "$name")
|
||||
|
||||
pve_running "$vmid" && { fail "$name is still running"; return 1; }
|
||||
|
||||
if pve_exists "$tpl"; then
|
||||
ok "$(printf '%-6s template %s already exists' "$name" "$tpl")"
|
||||
return 0
|
||||
fi
|
||||
pve_exists "$vmid" || { fail "$name has no VM to freeze"; return 1; }
|
||||
|
||||
qm template "$vmid" >/dev/null || { fail "qm template failed for $name"; return 1; }
|
||||
ok "$(printf '%-6s frozen as template %s' "$name" "$tpl")"
|
||||
}
|
||||
|
||||
backend_reset() {
|
||||
local name=$1 vmid tpl
|
||||
vmid=$(pve_vmid "$name")
|
||||
tpl=$(pve_template_vmid "$name")
|
||||
|
||||
pve_running "$vmid" && backend_stop "$name" >/dev/null 2>&1 || true
|
||||
pve_exists "$tpl" || { fail "$name has no template — run ./lab.sh snapshot first"; return 1; }
|
||||
|
||||
pve_exists "$vmid" && qm destroy "$vmid" --purge 1 >/dev/null 2>&1
|
||||
qm clone "$tpl" "$vmid" --name "norbourg-$name" >/dev/null \
|
||||
|| { fail "qm clone failed for $name"; return 1; }
|
||||
ok "$(printf '%-6s reverted from template %s' "$name" "$tpl")"
|
||||
}
|
||||
|
||||
backend_destroy() {
|
||||
local name=$1 vmid tpl
|
||||
vmid=$(pve_vmid "$name")
|
||||
tpl=$(pve_template_vmid "$name")
|
||||
|
||||
pve_running "$vmid" && backend_stop "$name" >/dev/null 2>&1 || true
|
||||
if pve_exists "$vmid"; then
|
||||
qm destroy "$vmid" --purge 1 >/dev/null 2>&1 || true
|
||||
fi
|
||||
if pve_exists "$tpl"; then
|
||||
qm destroy "$tpl" --purge 1 >/dev/null 2>&1 || true
|
||||
fi
|
||||
ok "$name removed"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------ transport
|
||||
# qm guest exec returns JSON; unwrap it without adding Python dependencies.
|
||||
_qga() {
|
||||
local name=$1; shift
|
||||
local vmid
|
||||
vmid=$(pve_vmid "$name")
|
||||
qm guest exec "$vmid" --timeout "${QGA_TIMEOUT:-180}" -- "$@"
|
||||
}
|
||||
|
||||
_qga_unwrap() {
|
||||
python3 - "$1" <<'PY'
|
||||
import json, sys
|
||||
try:
|
||||
data = json.loads(sys.argv[1])
|
||||
except Exception:
|
||||
print("could not parse guest agent output", file=sys.stderr)
|
||||
sys.exit(2)
|
||||
sys.stdout.write(data.get("out", ""))
|
||||
if data.get("err", "").strip():
|
||||
sys.stderr.write(data["err"])
|
||||
sys.exit(int(data.get("exitcode", 0)))
|
||||
PY
|
||||
}
|
||||
|
||||
backend_ps() {
|
||||
local name=$1 script=$2 json
|
||||
json=$(_qga "$name" powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command "$script" 2>/dev/null) \
|
||||
|| return 2
|
||||
_qga_unwrap "$json"
|
||||
}
|
||||
|
||||
backend_ready() {
|
||||
local name=$1 timeout=${2:-300}
|
||||
local deadline=$(( SECONDS + timeout )) vmid
|
||||
vmid=$(pve_vmid "$name")
|
||||
|
||||
while (( SECONDS < deadline )); do
|
||||
pve_running "$vmid" || { sleep 10; continue; }
|
||||
if _qga "$name" cmd.exe /c exit >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
sleep 10
|
||||
done
|
||||
fail "$name: guest agent not answering (is qemu-ga installed? see C:\\norbourg\\bootstrap.log)"
|
||||
return 1
|
||||
}
|
||||
|
||||
backend_start() {
|
||||
local name=$1 remote=$2
|
||||
backend_ps "$name" "
|
||||
Remove-Item -Force -ErrorAction SilentlyContinue '${remote}.done'
|
||||
schtasks.exe /End /TN NorbourgStage 2>\$null | Out-Null
|
||||
schtasks.exe /Delete /TN NorbourgStage /F 2>\$null | Out-Null
|
||||
\$tr = 'powershell.exe -NoProfile -ExecutionPolicy Bypass -File \"${remote}\"'
|
||||
schtasks.exe /Create /TN NorbourgStage /F /SC ONCE /ST 00:00 /RU SYSTEM /RL HIGHEST /TR \$tr | Out-Null
|
||||
schtasks.exe /Run /TN NorbourgStage | Out-Null
|
||||
"
|
||||
}
|
||||
|
||||
backend_wait() {
|
||||
local name=$1 remote=$2 timeout=${3:-1800}
|
||||
local deadline=$(( SECONDS + timeout )) out
|
||||
|
||||
while (( SECONDS < deadline )); do
|
||||
out=$(backend_ps "$name" "Test-Path '${remote}.done'" 2>/dev/null | tr -d '\r\n ')
|
||||
if [[ $out == True ]]; then
|
||||
backend_ps "$name" "Get-Content -Raw '${remote}.done'" 2>/dev/null | sed '/^$/d'
|
||||
return 0
|
||||
fi
|
||||
sleep 10
|
||||
done
|
||||
return 3
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------ peers
|
||||
# Generate one WireGuard config per participant, plus the router's wg0.conf.
|
||||
cmd_peers() {
|
||||
local names=("$@")
|
||||
(( ${#names[@]} )) || die "usage: ./lab.sh peers <name> [name...]"
|
||||
|
||||
have_cmd wg || die "wireguard-tools is required (apt install wireguard-tools)"
|
||||
|
||||
mkdir -p "$WG_DIR"
|
||||
chmod 700 "$WG_DIR"
|
||||
|
||||
if [[ ! -f $WG_DIR/server.key ]]; then
|
||||
( umask 077; wg genkey > "$WG_DIR/server.key" )
|
||||
wg pubkey < "$WG_DIR/server.key" > "$WG_DIR/server.pub"
|
||||
ok "server key generated"
|
||||
fi
|
||||
|
||||
local endpoint=${WG_ENDPOINT:-}
|
||||
if [[ -z $endpoint ]]; then
|
||||
local iface ip
|
||||
iface=$(ip route show default 2>/dev/null | awk '/default/{print $5; exit}')
|
||||
ip=$(ip -4 -o addr show dev "${iface:-vmbr0}" 2>/dev/null | awk '{print $4}' | cut -d/ -f1 | head -1)
|
||||
endpoint="${ip:-<LAN-IP>}:${WG_PORT}"
|
||||
else
|
||||
endpoint="${endpoint}:${WG_PORT}"
|
||||
fi
|
||||
|
||||
local i name addr priv pub psk router_peers=""
|
||||
local LAB_IFACE=${WG_LAB_IFACE:-eth1}
|
||||
for i in "${!names[@]}"; do
|
||||
name=${names[$i]}
|
||||
addr="10.10.10.$(( 101 + i ))/32"
|
||||
|
||||
( umask 077; wg genkey > "$WG_DIR/${name}.key" )
|
||||
wg pubkey < "$WG_DIR/${name}.key" > "$WG_DIR/${name}.pub"
|
||||
( umask 077; wg genpsk > "$WG_DIR/${name}.psk" )
|
||||
|
||||
priv=$(<"$WG_DIR/${name}.key")
|
||||
pub=$(<"$WG_DIR/${name}.pub")
|
||||
psk=$(<"$WG_DIR/${name}.psk")
|
||||
|
||||
cat > "$WG_DIR/${name}.conf" <<CONF
|
||||
[Interface]
|
||||
PrivateKey = ${priv}
|
||||
Address = ${addr}
|
||||
DNS = ${LAB_DC_IP}
|
||||
|
||||
[Peer]
|
||||
PublicKey = $(<"$WG_DIR/server.pub")
|
||||
PresharedKey = ${psk}
|
||||
Endpoint = ${endpoint}
|
||||
AllowedIPs = ${LAB_SUBNET}
|
||||
PersistentKeepalive = 25
|
||||
CONF
|
||||
chmod 600 "$WG_DIR/${name}.conf"
|
||||
|
||||
router_peers+="
|
||||
[Peer]
|
||||
# ${name}
|
||||
PublicKey = ${pub}
|
||||
PresharedKey = ${psk}
|
||||
AllowedIPs = ${addr}"
|
||||
ok "$(printf '%-10s %-16s %s' "$name" "${addr%/32}" "$WG_DIR/${name}.conf")"
|
||||
done
|
||||
|
||||
cat > "$WG_DIR/wg0.conf" <<CONF
|
||||
# Router VM — /etc/wireguard/wg0.conf, then: systemctl enable --now wg-quick@wg0
|
||||
#
|
||||
# The VM needs TWO interfaces:
|
||||
# eth0 on vmbr0 (your LAN) — optional, for management
|
||||
# eth1 on vmbr10 (the lab bridge) — give it 10.10.10.251/24
|
||||
# wg0 is a /32 inside the lab subnet so it does not collide with those /24s:
|
||||
# traffic to .250 goes through the tunnel, everything else through eth1.
|
||||
# Adjust LAB_IFACE below if your lab NIC is not eth1.
|
||||
[Interface]
|
||||
Address = 10.10.10.250/32
|
||||
ListenPort = ${WG_PORT}
|
||||
PrivateKey = $(<"$WG_DIR/server.key")
|
||||
PostUp = sysctl -w net.ipv4.ip_forward=1
|
||||
PostUp = nft add rule inet filter forward iifname "wg0" oifname "${LAB_IFACE}" accept
|
||||
PostUp = nft add rule inet filter forward iifname "${LAB_IFACE}" oifname "wg0" ct state established,related accept
|
||||
PostDown = nft delete rule inet filter forward iifname "wg0" oifname "${LAB_IFACE}" accept
|
||||
PostDown = nft delete rule inet filter forward iifname "${LAB_IFACE}" oifname "wg0" ct state established,related accept
|
||||
${router_peers}
|
||||
CONF
|
||||
chmod 600 "$WG_DIR/wg0.conf"
|
||||
|
||||
printf '\n'
|
||||
ok "peer configs in ${WG_DIR}"
|
||||
info " router config: ${WG_DIR}/wg0.conf (address 10.10.10.250 on the lab bridge)"
|
||||
}
|
||||
|
||||
|
||||
# After a successful install, stop booting from the installer CD: otherwise
|
||||
# every boot waits five seconds and a stray keypress re-enters Setup.
|
||||
backend_finalize() {
|
||||
local name=$1 vmid
|
||||
vmid=$(pve_vmid "$name")
|
||||
qm set "$vmid" --boot 'order=sata0' --delete ide2 >/dev/null 2>&1 || true
|
||||
ok "$(printf '%-6s boots from disk (installer ISO detached)' "$name")"
|
||||
}
|
||||
@@ -0,0 +1,243 @@
|
||||
# Laboratoire Norbourg — atelier d'introduction au pentest de domaine
|
||||
|
||||
Laboratoire Active Directory isolé, déployé par script, pour initier des collègues au pentest de
|
||||
domaine. L'objectif : partir d'un accès anonyme et **prendre le contrôle du domaine**, comme
|
||||
sur une plateforme de type Hack The Box.
|
||||
|
||||
> **État : fonctionnel.** Le parcours complet (site → SMB → Kerberoasting → WinRM → ACL →
|
||||
> droits de réplication, puis DCSync) a été validé sur la plateforme `qemu`. La plateforme
|
||||
> `proxmox` est écrite et vérifiée statiquement, mais n'a pas encore tourné sur un hôte Proxmox
|
||||
> réel — y compris le déploiement des Kali par l'agent invité, testé hors Proxmox seulement.
|
||||
|
||||
## Deux plateformes, un même contenu
|
||||
|
||||
| | `qemu` | `proxmox` |
|
||||
|---|---|---|
|
||||
| Cible | n'importe quel Linux avec KVM | Proxmox VE 8.x |
|
||||
| Commande | `./platforms/qemu/lab.sh` | `./platforms/proxmox/lab.sh` |
|
||||
| Configuration | `platforms/qemu/lab.conf` | `platforms/proxmox/lab.conf` |
|
||||
| Disques | qcow2 + `chattr +C` sur btrfs | stockage Proxmox (`local-lvm`, `local-zfs`…) |
|
||||
| Réseau | pont `br-lab` créé par le script | pont `vmbr10` créé à la main dans l'interface |
|
||||
| Réinitialisation | base + couche jetable (~2 s) | gabarit + clone |
|
||||
| Accès participants | route vers `10.10.10.0/24` | console web Proxmox, une Kali par personne |
|
||||
|
||||
Le contenu commun — scripts PowerShell, site archivé, documentation, solution — vit dans
|
||||
`content/` et `docs/`. Les deux plateformes ne diffèrent que par la couche de virtualisation.
|
||||
|
||||
## Topologie
|
||||
|
||||
```
|
||||
participant (Kali)
|
||||
│ route 10.10.10.0/24 via 10.10.10.1 (ou tunnel WireGuard)
|
||||
▼
|
||||
hôte 10.10.10.1 / 10.10.10.230 pont isolé
|
||||
├── DC01 10.10.10.10 contrôleur de domaine, DNS
|
||||
├── FS01 10.10.10.20 serveur de fichiers, site 2002, partage Public
|
||||
└── WS01 10.10.10.31 poste de travail
|
||||
```
|
||||
|
||||
## Prérequis
|
||||
|
||||
- Hôte Linux avec KVM, 16 Go de RAM et ~80 Go libres, **ou** un hôte Proxmox VE 8.x.
|
||||
- Un accès `sudo` une seule fois sur la plateforme `qemu` (pont et pare-feu).
|
||||
- Une machine Kali sur le même réseau local, ou un tunnel WireGuard.
|
||||
|
||||
---
|
||||
|
||||
## Démarrage — plateforme `qemu` (Linux générique)
|
||||
|
||||
```bash
|
||||
cd platforms/qemu
|
||||
./lab.sh check # valide hôte, stockage, réseau, configuration
|
||||
./lab.sh init # arborescence + chattr +C
|
||||
sudo ./setup-network.sh # pont br-lab et isolation — seule étape root
|
||||
./lab.sh isos # télécharge 5,6 Go d'images Windows
|
||||
./lab.sh build # installe les 3 VM sans intervention (~20 min)
|
||||
./lab.sh provision # domaine, comptes, ACL, drapeaux (~15 min)
|
||||
./lab.sh web --sync # publie le site 2002 sur FS01
|
||||
./lab.sh save # fige l'état dans la base et redémarre
|
||||
```
|
||||
|
||||
## Démarrage — plateforme `proxmox`
|
||||
|
||||
1. Remplir `platforms/proxmox/lab.conf` : stockages, pont, adresse de l'hôte.
|
||||
2. Créer le pont dans l'interface Proxmox : *Datacenter > nœud > Network > Create > Linux
|
||||
Bridge*, nom `vmbr10`, **aucun port**, IPv4 `10.10.10.1/24`, pas de passerelle.
|
||||
3. Puis :
|
||||
|
||||
```bash
|
||||
cd platforms/proxmox
|
||||
./lab.sh check # refuse de continuer si la config ne correspond pas à l'hôte
|
||||
./lab.sh init
|
||||
./lab.sh isos
|
||||
./lab.sh build
|
||||
./lab.sh provision
|
||||
./lab.sh web --sync
|
||||
./lab.sh snapshot # convertit les VM en gabarits
|
||||
./lab.sh up # redémarre le laboratoire depuis les gabarits
|
||||
|
||||
./lab.sh kali install # une Kali par participant (5 par défaut)
|
||||
./lab.sh users alice bob carol # comptes Proxmox + URL de console
|
||||
```
|
||||
|
||||
Les participants n'ont rien à installer : chacun ouvre son URL de console dans un navigateur,
|
||||
se connecte avec le compte Proxmox imprimé, et arrive sur un bureau Kali déjà configuré (DNS du
|
||||
laboratoire, liste de mots, outils). Voir « Participants » plus bas.
|
||||
|
||||
Sans accès au serveur git sur l'hôte Proxmox, construisez une archive autonome :
|
||||
|
||||
```bash
|
||||
./build-bundle.sh proxmox # produit dist/norbourg-proxmox.tar.gz
|
||||
scp dist/norbourg-proxmox.tar.gz root@pve:/root/
|
||||
```
|
||||
|
||||
## Machine d'attaque (Kali)
|
||||
|
||||
L'image QEMU officielle de Kali contient déjà `nxc`, Impacket, `evil-winrm`, `hashcat` et
|
||||
`bloodhound-python`. Le parcours ne demande rien d'autre : `bloodyAD` est un confort, pas une
|
||||
dépendance.
|
||||
|
||||
### Plateforme `qemu`
|
||||
|
||||
```bash
|
||||
./lab.sh kali install # télécharge ~4 Go, extrait, prépare une couche jetable
|
||||
./lab.sh kali up # démarre (VNC 127.0.0.1:5909, SSH 127.0.0.1:2222)
|
||||
./lab.sh kali snapshot # fige l'état courant (outils, liste de mots, DNS) dans la base
|
||||
./lab.sh kali reset # repart de la base figée
|
||||
./lab.sh kali down
|
||||
```
|
||||
|
||||
Identifiants par défaut : `kali` / `kali`. La VM a deux cartes : le pont du laboratoire
|
||||
(adresse fournie par le DHCP de DC01) et un réseau utilisateur qui permet `apt` sans ouvrir de
|
||||
passage vers le réseau du bureau.
|
||||
|
||||
Un petit ISO « outils » est monté dans la VM : il contient `norbourg.txt`, la liste de mots de
|
||||
l'atelier. À récupérer une fois au premier démarrage, puis à figer avec `./lab.sh kali snapshot`
|
||||
pour que `reset` la conserve :
|
||||
|
||||
```bash
|
||||
sudo mkdir -p /opt/norbourg/wordlists
|
||||
sudo mount /dev/sr0 /mnt && sudo cp /mnt/norbourg.txt /opt/norbourg/wordlists/
|
||||
sudo cp /mnt/bh_clues.py /opt/norbourg/ && sudo chmod +x /opt/norbourg/bh_clues.py
|
||||
```
|
||||
|
||||
Pour ajouter des outils qui ne sont pas dans l'image (Internet requis, donc avant de basculer le
|
||||
DNS sur le DC) : `content/scripts/kali-setup.sh`.
|
||||
|
||||
### Plateforme `proxmox`
|
||||
|
||||
Aucune manipulation dans la VM : `kali install` importe l'image une fois, en fait un gabarit,
|
||||
puis crée et configure chaque clone par l'agent invité — adresse fixe réservée sur DC01, nom,
|
||||
liste de mots copiée depuis l'ISO d'outils.
|
||||
|
||||
```bash
|
||||
./lab.sh kali install # KALI_COUNT clones (5 par défaut)
|
||||
./lab.sh kali status
|
||||
./lab.sh kali up | down
|
||||
./lab.sh kali configure # rejoue la configuration si un clone a échoué
|
||||
./lab.sh kali reset # détruit et recrée les clones
|
||||
```
|
||||
|
||||
Les Kali n'ont **pas** Internet : c'est volontaire, le pont n'a aucun port vers l'extérieur.
|
||||
Tout ce que demande l'atelier est déjà dans l'image, et la liste de mots arrive par l'ISO
|
||||
d'outils.
|
||||
|
||||
`KALI_XRDP=1` (par défaut) installe `xrdp` dans le gabarit pour ceux qui veulent un bureau
|
||||
graphique via un client RDP. `./lab.sh kali rdp` expose un port par siège (3381, 3382…).
|
||||
|
||||
## Participants
|
||||
|
||||
Chaque personne reçoit un compte Proxmox limité à sa propre VM :
|
||||
|
||||
```bash
|
||||
./lab.sh users alice bob carol dave erin
|
||||
```
|
||||
|
||||
La commande crée `alice@pve`, etc., accorde le rôle `PVEVMUser` sur la VM correspondante et
|
||||
imprime le mot de passe ainsi que l'URL de console :
|
||||
|
||||
```
|
||||
USER PASSWORD KALI CONSOLE URL
|
||||
alice Xk3... vm 1301 https://pve:8006/?console=kvm&novnc=1&vmid=1301&node=pve&resize=scale
|
||||
```
|
||||
|
||||
L'URL ouvre directement la console noVNC de la Kali. Identifiants dans la VM : `kali` / `kali`.
|
||||
Aucun VPN, aucune route à ajouter, aucun outil à installer sur le poste du participant.
|
||||
|
||||
Pour plus de cinq personnes, ajustez `KALI_COUNT` dans `platforms/proxmox/lab.conf`, relancez
|
||||
`./lab.sh kali install`, puis `./lab.sh users` avec la liste complète : les sièges sont attribués
|
||||
dans l'ordre (`alice` → vm 1301, `bob` → vm 1302, …).
|
||||
|
||||
Dimensionnement : `KALI_COUNT × KALI_RAM` s'ajoute aux 12 Go du laboratoire. Avec les valeurs par
|
||||
défaut (5 × 3 Go), comptez environ 30 Go de RAM sur l'hôte ; `./lab.sh check` compare la somme à
|
||||
la mémoire de l'hôte et prévient avant le build.
|
||||
|
||||
## Commandes
|
||||
|
||||
| Commande | Effet |
|
||||
|---|---|
|
||||
| `check` | préflight ; refuse si le stockage ou la config sont inadaptés |
|
||||
| `init` | arborescence, désactivation du CoW |
|
||||
| `isos` | télécharge les images d'évaluation Microsoft |
|
||||
| `seeds` | génère les fichiers de réponse et les ISO d'amorçage |
|
||||
| `build` | disques + installation sans intervention |
|
||||
| `provision [--role N]` | domaine, comptes, ACL, partage, drapeaux |
|
||||
| `web [--sync]` | assemble le site et le pousse sur FS01 |
|
||||
| `save` | **la commande de clôture** : fige l'état courant dans la base, puis démarre |
|
||||
| `snapshot [--update]` | fige une base ; `--update` y intègre les changements, sans redémarrer |
|
||||
| `up` / `down` | démarre (DC d'abord) / arrête |
|
||||
| `reset` | repart de la base |
|
||||
| `status` / `doctor` | tableau des VM / bilan de santé |
|
||||
| `vnc <vm>` | console graphique (plateforme qemu) |
|
||||
| `kali` | installe et pilote les VM d'attaque (voir plus haut) |
|
||||
| `users <noms>` | comptes Proxmox + URL de console, une Kali par personne (proxmox) |
|
||||
| `answers` | affiche la solution de l'instructeur |
|
||||
| `peers` | configs WireGuard (plateforme proxmox) |
|
||||
|
||||
## Structure du dépôt
|
||||
|
||||
| Chemin | Rôle |
|
||||
|---|---|
|
||||
| `platforms/qemu/` | point d'entrée et configuration pour un Linux générique |
|
||||
| `platforms/proxmox/` | point d'entrée et configuration pour Proxmox VE |
|
||||
| `content/lib/` | commandes communes, préflight, orchestration |
|
||||
| `content/windows/` | scripts PowerShell par machine |
|
||||
| `content/seed/` | fichier de réponse et charge utile des ISO d'amorçage |
|
||||
| `content/site-src/` | site Norbourg 2002 : miroir et images retouchées |
|
||||
| `content/web/` | site assemblé et fichiers pièges |
|
||||
| `content/scripts/` | assistants partagés (WinRM, préparation du site, liste de mots) |
|
||||
| `docs/` | documentation de l'atelier, en français |
|
||||
| `docs/slides/` | présentation d'introduction et de débriefing (`.pptx` + script de génération) |
|
||||
| `answers/` | solution complète — **ignoré par git** |
|
||||
| `build-bundle.sh` | fabrique une archive autonome par plateforme |
|
||||
|
||||
## Isolation
|
||||
|
||||
Rien du laboratoire ne doit joindre le réseau de bureau ni Internet :
|
||||
|
||||
- le pont du laboratoire n'a aucun port vers l'extérieur ;
|
||||
- seul le sens participant → laboratoire est autorisé, sur les ports nécessaires
|
||||
(DNS, Kerberos, LDAP, SMB, WinRM, HTTP) ;
|
||||
- le sens laboratoire → bureau est rejeté.
|
||||
|
||||
Sur `qemu`, c'est le pare-feu de l'hôte qui l'applique ; sur `proxmox`, le pont sans port suffit,
|
||||
et le routeur WireGuard ne fait que router.
|
||||
|
||||
## Contenu archivé
|
||||
|
||||
`content/site-src/` contient une capture du site public de Norbourg tel qu'il existait en 2002,
|
||||
provenant de la Wayback Machine. Il sert de décor au laboratoire et de point d'entrée pour les
|
||||
participants. Usage strictement interne et pédagogique.
|
||||
|
||||
## Session 2
|
||||
|
||||
Le dossier [`session2/`](../session2/README.md) contient la conception d'une deuxième séance : vol de
|
||||
matériel d'authentification dans LSASS (mimikatz, overpass-the-hash, pass-the-ticket). **Rien
|
||||
n'y est implémenté** — c'est un plan, pas du code. Le laboratoire décrit ci-dessus reste la
|
||||
version de référence.
|
||||
|
||||
## Avertissement
|
||||
|
||||
Laboratoire jetable. Les images Windows sont des versions d'évaluation Microsoft (180 jours pour
|
||||
Server, 90 jours pour Windows 11) : à reconstruire périodiquement, jamais à exposer, jamais en
|
||||
production. Les vulnérabilités sont volontaires.
|
||||
@@ -116,6 +116,41 @@ _start_lab() {
|
||||
backend_launch "$name" run || { fail "$name did not start"; return 1; }
|
||||
fi
|
||||
done
|
||||
|
||||
# Return only once every guest answers: running `doctor` the instant `up`
|
||||
# printed its last line used to report false failures during boot.
|
||||
step "wait for the guests"
|
||||
local notready=0
|
||||
for name in "${VM_NAMES[@]}"; do
|
||||
if backend_ready "$name" 300; then
|
||||
ok "$(printf '%-6s ready' "$name")"
|
||||
else
|
||||
warn "$name did not answer in time"
|
||||
notready=1
|
||||
fi
|
||||
done
|
||||
if (( notready )); then
|
||||
warn "skipping the directory check: not every guest answered"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# WinRM answers before the directory does. A doctor run right after up saw
|
||||
# "stable path missing" and "replication rights missing" on a healthy lab
|
||||
# because the DC was still starting AD.
|
||||
if ! vm_index dc01 >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
step "wait for the domain"
|
||||
local deadline=$(( SECONDS + 240 ))
|
||||
while (( SECONDS < deadline )); do
|
||||
if backend_ps dc01 'Import-Module ActiveDirectory; (Get-ADDomain).DNSRoot' >/dev/null 2>&1; then
|
||||
ok "directory services answer"
|
||||
return 0
|
||||
fi
|
||||
sleep 5
|
||||
done
|
||||
warn "the domain did not answer in time — check with ./lab.sh doctor"
|
||||
return 1
|
||||
}
|
||||
|
||||
cmd_up() {
|
||||
@@ -0,0 +1,172 @@
|
||||
# shellcheck shell=bash
|
||||
# cmd_doctor — end-to-end health check of the running laboratory.
|
||||
|
||||
_d_ok() { ok "$*"; }
|
||||
_d_warn() { warn "$*"; DOCTOR_WARNS=$(( DOCTOR_WARNS + 1 )); }
|
||||
_d_fail() { fail "$*"; DOCTOR_FAILS=$(( DOCTOR_FAILS + 1 )); }
|
||||
|
||||
cmd_doctor() {
|
||||
DOCTOR_FAILS=0
|
||||
DOCTOR_WARNS=0
|
||||
local i name ip
|
||||
|
||||
step "host"
|
||||
if ip link show "$LAB_BRIDGE" >/dev/null 2>&1; then
|
||||
_d_ok "bridge ${LAB_BRIDGE} present"
|
||||
else
|
||||
_d_fail "bridge ${LAB_BRIDGE} missing — run sudo ./platforms/qemu/setup-network.sh"
|
||||
fi
|
||||
|
||||
step "machines"
|
||||
for i in "${!VM_NAMES[@]}"; do
|
||||
name=${VM_NAMES[$i]}
|
||||
ip=${VM_IPS[$i]}
|
||||
|
||||
if ! backend_running "$name"; then
|
||||
_d_fail "$name is not running — ./lab.sh up"
|
||||
continue
|
||||
fi
|
||||
|
||||
if tcp_open "$ip" 445; then
|
||||
_d_ok "$(printf '%-6s %-14s smb up' "$name" "$ip")"
|
||||
else
|
||||
_d_warn "$(printf '%-6s %-14s smb not answering' "$name" "$ip")"
|
||||
fi
|
||||
|
||||
if [[ $name == dc01 || $name == ws01 || $name == fs01 ]]; then
|
||||
if tcp_open "$ip" 5985; then
|
||||
_d_ok "$(printf '%-6s %-14s winrm up' "$name" "$ip")"
|
||||
else
|
||||
_d_warn "$(printf '%-6s %-14s winrm not answering' "$name" "$ip")"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
step "domain"
|
||||
if have_cmd dig; then
|
||||
local www
|
||||
www=$(dig +short +time=2 +tries=1 "@$LAB_DC_IP" www.norbourg.lab 2>/dev/null | head -1)
|
||||
if [[ $www == 10.10.10.20 ]]; then
|
||||
_d_ok "dns: www.norbourg.lab -> $www"
|
||||
else
|
||||
_d_fail "dns: www.norbourg.lab did not resolve via ${LAB_DC_IP} (got '${www:-nothing}')"
|
||||
fi
|
||||
local srv
|
||||
srv=$(dig +short +time=2 +tries=1 "@$LAB_DC_IP" SRV _ldap._tcp.dc._msdcs.norbourg.lab 2>/dev/null | head -1)
|
||||
if [[ -n $srv ]]; then
|
||||
_d_ok "dns: ldap SRV record present"
|
||||
else
|
||||
_d_fail "dns: ldap SRV record missing — AD discovery would fail"
|
||||
fi
|
||||
else
|
||||
_d_warn "dig not installed, DNS checks skipped"
|
||||
fi
|
||||
|
||||
step "lab state"
|
||||
_lab_state
|
||||
|
||||
step "web"
|
||||
local code
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 "http://10.10.10.20/" 2>/dev/null || true)
|
||||
if [[ $code == 200 ]]; then
|
||||
_d_ok "site answers on 10.10.10.20"
|
||||
else
|
||||
_d_fail "site not answering (${code:-timeout}) — ./lab.sh web --sync"
|
||||
fi
|
||||
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 "http://10.10.10.10/" 2>/dev/null || true)
|
||||
if [[ $code == 200 ]]; then
|
||||
_d_ok "site answers on the domain name (http://norbourg.lab)"
|
||||
else
|
||||
_d_warn "http://norbourg.lab does not answer (${code:-timeout}) — re-run provision --role dc01"
|
||||
fi
|
||||
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 "http://10.10.10.20/public/IT-inventaire.txt" 2>/dev/null || true)
|
||||
if [[ $code == 200 ]]; then
|
||||
_d_ok "entry point reachable: /public/IT-inventaire.txt"
|
||||
else
|
||||
_d_fail "entry point missing (${code:-timeout})"
|
||||
fi
|
||||
|
||||
step "share"
|
||||
if have_cmd smbclient; then
|
||||
if smbclient //10.10.10.20/Public -U 'NORBOURG\helpdesk1%Welcome2024!' -c 'ls' 2>/dev/null | grep -q 'IT-inventaire'; then
|
||||
_d_ok "Public share reachable with the leaked credential"
|
||||
else
|
||||
_d_warn "Public share not readable as helpdesk1 (domain channel or DNS?)"
|
||||
fi
|
||||
else
|
||||
_d_warn "smbclient not installed, share check skipped"
|
||||
fi
|
||||
|
||||
printf '\n'
|
||||
if (( DOCTOR_FAILS )); then
|
||||
fail "${DOCTOR_FAILS} problem(s), ${DOCTOR_WARNS} warning(s)"
|
||||
return 1
|
||||
fi
|
||||
ok "laboratory healthy · ${DOCTOR_WARNS} warning(s)"
|
||||
}
|
||||
|
||||
|
||||
# The puzzle has invariants that services do not reveal: a delegated right, an
|
||||
# SPN, disabled pre-authentication, a password policy, replication rights.
|
||||
# SDProp quietly reverts ACEs on protected objects, so the target must stay
|
||||
# outside protected groups — worth checking every time.
|
||||
_lab_state() {
|
||||
local out key value
|
||||
out=$(backend_ps dc01 '
|
||||
Import-Module ActiveDirectory,DnsServer
|
||||
$dom = Get-ADDomain
|
||||
$base = $dom.DistinguishedName
|
||||
$acl = Get-Acl ("AD:\" + (Get-ADUser t.smith).DistinguishedName)
|
||||
"ace=" + @($acl.Access | Where-Object { $_.IdentityReference.Value -like "*svc_backup*" }).Count
|
||||
$plainAcl = Get-Acl ("AD:\" + (Get-ADUser m.legault).DistinguishedName)
|
||||
"ace_plain=" + @($plainAcl.Access | Where-Object { $_.IdentityReference.Value -like "*svc_backup*" }).Count
|
||||
"plain_enabled=" + (Get-ADUser m.legault).Enabled
|
||||
"mcount=" + (Get-ADUser m.legault -Properties adminCount).adminCount
|
||||
"repl=" + @((dsacls.exe $base | Select-String "Sauvegarde-AD")).Count
|
||||
"share=" + ((Get-SmbShare -Name "Sauvegarde$" -ErrorAction SilentlyContinue) -ne $null)
|
||||
"root=" + (Test-Path C:\flag\root.txt)
|
||||
"oldflag=" + (Test-Path C:\Sauvegarde\root.txt)
|
||||
"spn=" + @((Get-ADUser svc_backup -Properties ServicePrincipalNames).ServicePrincipalNames).Count
|
||||
"preauth=" + (Get-ADUser j.contractor -Properties DoesNotRequirePreAuth).DoesNotRequirePreAuth
|
||||
"minage=" + (Get-ADDefaultDomainPasswordPolicy).MinPasswordAge.TotalHours
|
||||
"txt=" + ((Get-DnsServerResourceRecord -ZoneName norbourg.lab -Name yourlove -EA SilentlyContinue) -ne $null)
|
||||
"dhcp=" + ((Get-DhcpServerv4Scope -EA SilentlyContinue) -ne $null)
|
||||
"kali_res=" + @((Get-DhcpServerv4Reservation -ScopeId 10.10.10.0 -EA SilentlyContinue) | Where-Object { $_.IPAddress -eq "10.10.10.101" }).Count
|
||||
' 2>/dev/null) || { _d_warn "cannot query DC01 for lab state"; return; }
|
||||
|
||||
while IFS='=' read -r key value; do
|
||||
value=${value//$'\r'/}
|
||||
case $key in
|
||||
ace) if [[ $value -ge 1 ]]; then _d_fail "decoy ACE still on t.smith — a Domain Admin shortcut until SDProp runs"
|
||||
else _d_ok "decoy ACE absent on t.smith (protected object, as designed)"; fi ;;
|
||||
ace_plain) if [[ $value -ge 1 ]]; then _d_ok "stable path: svc_backup has an ACE on m.legault"
|
||||
else _d_fail "stable path missing (ACE on m.legault)"; fi ;;
|
||||
plain_enabled) if [[ $value == True ]]; then _d_ok "m.legault account enabled"
|
||||
else _d_fail "m.legault is disabled — the path is dead"; fi ;;
|
||||
mcount) if [[ -z $value || $value == 0 ]]; then _d_ok "m.legault outside protected groups"
|
||||
else _d_fail "adminCount=$value: m.legault is protected, SDProp will wipe the ACE"; fi ;;
|
||||
repl) if [[ $value -ge 2 ]]; then _d_ok "Sauvegarde-AD holds replication rights (DCSync)"
|
||||
else _d_fail "replication rights missing on Sauvegarde-AD"; fi ;;
|
||||
share) if [[ $value == True ]]; then _d_ok "backup share present (Sauvegarde$)"
|
||||
else _d_fail "Sauvegarde\$ share missing"; fi ;;
|
||||
root) if [[ $value == True ]]; then _d_ok "root.txt in C:\flag (administrators only)"
|
||||
else _d_fail "root.txt missing from C:\flag"; fi ;;
|
||||
oldflag) if [[ $value == True ]]; then _d_fail "root.txt still readable on the backup share"
|
||||
else _d_ok "flag not exposed on the backup share"; fi ;;
|
||||
spn) if [[ $value -ge 1 ]]; then _d_ok "service account: SPN present"
|
||||
else _d_fail "svc_backup has no SPN"; fi ;;
|
||||
preauth) if [[ $value == True ]]; then _d_ok "pre-auth disabled on j.contractor"
|
||||
else _d_fail "j.contractor still requires pre-auth"; fi ;;
|
||||
minage) if [[ $value == 0 ]]; then _d_ok "minimum password age: 0"
|
||||
else _d_fail "minimum password age is $value h"; fi ;;
|
||||
txt) if [[ $value == True ]]; then _d_ok "easter egg TXT record"
|
||||
else _d_warn "yourlove TXT record missing"; fi ;;
|
||||
dhcp) if [[ $value == True ]]; then _d_ok "DHCP scope present"
|
||||
else _d_fail "DHCP scope missing"; fi ;;
|
||||
kali_res) if [[ $value -ge 1 ]]; then _d_ok "DHCP reservation 10.10.10.101"
|
||||
else _d_fail "Kali reservation missing"; fi ;;
|
||||
esac
|
||||
done <<< "$out"
|
||||
}
|
||||
@@ -12,6 +12,43 @@ _kali_pid() { printf '%s/run/kali.pid' "$LAB_ROOT"; }
|
||||
_kali_log() { printf '%s/run/kali.log' "$LAB_ROOT"; }
|
||||
|
||||
_kali_installed() { [[ -f $(_kali_base) ]]; }
|
||||
_kali_tools_iso() { printf '%s/seeds/kali-tools.iso' "$LAB_ROOT"; }
|
||||
|
||||
# The stock Kali image ships without the lab wordlist. A small ISO carries it
|
||||
# into the guest, so a fresh redeploy is reproducible without network access.
|
||||
_kali_build_tools() {
|
||||
local iso dir
|
||||
iso=$(_kali_tools_iso)
|
||||
dir=$(mktemp -d)
|
||||
|
||||
mkdir -p "$(dirname "$iso")"
|
||||
cp "$CONTENT_DIR/scripts/wordlists/norbourg.txt" "$dir/"
|
||||
cp "$CONTENT_DIR/scripts/bh_clues.py" "$dir/"
|
||||
cat > "$dir/README.txt" <<'EOF'
|
||||
Outils de l'atelier Norbourg
|
||||
============================
|
||||
|
||||
norbourg.txt : liste de mots ciblee (1716 entrees), dimensionnee pour que le
|
||||
cassage prenne quelques secondes.
|
||||
bh_clues.py : lit les JSON de bloodhound-python et imprime les droits
|
||||
exploitables d'un compte (outil concu pour ce laboratoire).
|
||||
|
||||
Installation dans Kali :
|
||||
|
||||
sudo mkdir -p /opt/norbourg/wordlists
|
||||
sudo cp /media/cdrom/norbourg.txt /opt/norbourg/wordlists/
|
||||
sudo chmod 644 /opt/norbourg/wordlists/norbourg.txt
|
||||
sudo cp /media/cdrom/bh_clues.py /opt/norbourg/
|
||||
sudo chmod +x /opt/norbourg/bh_clues.py
|
||||
EOF
|
||||
if have_cmd genisoimage; then
|
||||
genisoimage -quiet -volid NORBOURG_TOOLS -J -R -o "$iso" "$dir"
|
||||
else
|
||||
xorriso -as mkisofs -quiet -V NORBOURG_TOOLS -J -R -o "$iso" "$dir"
|
||||
fi
|
||||
rm -rf "$dir"
|
||||
ok "tool ISO: $iso"
|
||||
}
|
||||
|
||||
_kali_ensure_overlay() {
|
||||
local base overlay
|
||||
@@ -30,8 +67,9 @@ cmd_kali() {
|
||||
up) _kali_up ;;
|
||||
down) _kali_down ;;
|
||||
reset) _kali_reset ;;
|
||||
snapshot) _kali_snapshot ;;
|
||||
status) _kali_status ;;
|
||||
*) info "usage: ./lab.sh kali install|up|down|reset|status"; return 2 ;;
|
||||
*) info "usage: ./lab.sh kali install|up|down|reset|snapshot|status"; return 2 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
@@ -70,6 +108,7 @@ _kali_install() {
|
||||
fi
|
||||
ok "base image: $(du -h "$base" | cut -f1) (${KALI_DISK_GB:-40}G nominal)"
|
||||
_kali_ensure_overlay
|
||||
_kali_build_tools
|
||||
|
||||
printf '\n'
|
||||
ok "Kali installed — ./lab.sh kali up"
|
||||
@@ -91,9 +130,15 @@ _kali_up() {
|
||||
vnc=${KALI_VNC_DISPLAY:-9}
|
||||
|
||||
mkdir -p "$LAB_ROOT/run"
|
||||
[[ -f $(_kali_tools_iso) ]] || _kali_build_tools
|
||||
|
||||
# net0: the lab bridge (DHCP from DC01). net1: user networking so apt works
|
||||
# without punching a hole through the lab isolation policy.
|
||||
local cd_args=()
|
||||
if [[ -f $(_kali_tools_iso) ]]; then
|
||||
cd_args=( -drive "if=none,id=cd1,media=cdrom,file=$(_kali_tools_iso)" -device "ide-cd,drive=cd1,bus=ide.1" )
|
||||
fi
|
||||
|
||||
nohup qemu-system-x86_64 \
|
||||
-name norbourg-kali \
|
||||
-machine q35,accel=kvm -cpu host \
|
||||
@@ -107,6 +152,7 @@ _kali_up() {
|
||||
-netdev "user,id=net1,hostfwd=tcp:127.0.0.1:${KALI_SSH_PORT:-2222}-:22" \
|
||||
-device "e1000,netdev=net1" \
|
||||
-monitor "unix:$LAB_ROOT/run/kali.monitor,server,nowait" \
|
||||
"${cd_args[@]}" \
|
||||
-display none -vnc "127.0.0.1:$vnc" \
|
||||
>>"$(_kali_log)" 2>&1 &
|
||||
printf '%s\n' "$!" > "$(_kali_pid)"
|
||||
@@ -115,6 +161,7 @@ _kali_up() {
|
||||
if kill -0 "$(<"$(_kali_pid)")" 2>/dev/null; then
|
||||
ok "Kali started · vnc 127.0.0.1:$(( 5900 + vnc )) · ssh 127.0.0.1:${KALI_SSH_PORT:-2222}"
|
||||
info " login kali/kali · bridge address via DHCP (${KALI_IP:-10.10.10.101} reserved)"
|
||||
info " wordlist on the tool CD: mount /dev/sr0 /mnt && cp /mnt/norbourg.txt /opt/norbourg/wordlists/"
|
||||
else
|
||||
fail "Kali failed to start — see $(_kali_log)"
|
||||
return 1
|
||||
@@ -136,6 +183,27 @@ _kali_down() {
|
||||
ok "Kali stopped"
|
||||
}
|
||||
|
||||
# Fold the current overlay into the base image: wordlist, DNS, packages and
|
||||
# any tooling you installed survive a reset from then on.
|
||||
_kali_snapshot() {
|
||||
local overlay
|
||||
_kali_installed || die "Kali is not installed"
|
||||
overlay=$(_kali_disk)
|
||||
|
||||
_kali_down >/dev/null 2>&1 || true
|
||||
|
||||
if [[ ! -f $overlay ]]; then
|
||||
ok "nothing to commit — no working overlay"
|
||||
return 0
|
||||
fi
|
||||
|
||||
step "commit the overlay into ${KALI_NAME:-kali}'s base image"
|
||||
qemu-img commit -q "$overlay" || die "qemu-img commit failed"
|
||||
rm -f "$overlay"
|
||||
_kali_ensure_overlay
|
||||
ok "baseline updated: ./lab.sh kali reset now returns to this state"
|
||||
}
|
||||
|
||||
_kali_reset() {
|
||||
local overlay
|
||||
_kali_installed || die "Kali is not installed"
|
||||
@@ -26,6 +26,11 @@ cmd_destroy() {
|
||||
info "kali stopped; base image kept ($(du -h "$(_kali_base)" | cut -f1))"
|
||||
fi
|
||||
|
||||
# Platforms that manage extra VMs (participant Kali clones) clean up here.
|
||||
if declare -F platform_destroy_extra >/dev/null; then
|
||||
platform_destroy_extra
|
||||
fi
|
||||
|
||||
step "generated artifacts"
|
||||
rm -rf "$LAB_ROOT/seeds" "$LAB_ROOT/run" "$LAB_ROOT/provision"
|
||||
ok "seed ISOs, runtime state and provisioning scratch removed"
|
||||
@@ -40,3 +45,6 @@ cmd_peers() { planned peers; }
|
||||
|
||||
# Overridden by the qemu platform, which ships the Kali image helper.
|
||||
cmd_kali() { planned kali; }
|
||||
|
||||
# Participant accounts are a Proxmox concern (console access per VM).
|
||||
cmd_users() { planned users; }
|
||||
@@ -53,3 +53,28 @@ cmd_reset() {
|
||||
printf '\n'
|
||||
ok "laboratory reset — previous state discarded"
|
||||
}
|
||||
|
||||
|
||||
# The closing step of every change: freeze the current state into the
|
||||
# baseline, then bring the lab back up. Falls back to a first-time snapshot
|
||||
# when no baseline exists yet.
|
||||
cmd_save() {
|
||||
local name need_full=0
|
||||
|
||||
if declare -F backend_has_baseline >/dev/null; then
|
||||
for name in "${VM_NAMES[@]}"; do
|
||||
backend_has_baseline "$name" || need_full=1
|
||||
done
|
||||
else
|
||||
need_full=1
|
||||
fi
|
||||
|
||||
if (( need_full )); then
|
||||
cmd_snapshot
|
||||
else
|
||||
cmd_snapshot --update
|
||||
fi
|
||||
|
||||
step "start"
|
||||
_start_lab
|
||||
}
|
||||
@@ -51,6 +51,11 @@ _web_sync() {
|
||||
tcp_open "$ip" 445 || die "fs01 SMB is not reachable — is it provisioned?"
|
||||
have_cmd smbclient || die "smbclient is required to push the site"
|
||||
|
||||
# Clear the staging folder first: smbclient only adds, so an old file would
|
||||
# otherwise come back on every sync.
|
||||
backend_ready fs01 120 >/dev/null 2>&1 || true
|
||||
backend_ps fs01 "Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'C:\\norbourg\\site'" >/dev/null 2>&1 || true
|
||||
|
||||
# Bulk copy goes over SMB: WinRM caps the command line at ~8 KB.
|
||||
smbclient "//$ip/C\$" -W "$NETBIOS" \
|
||||
-U "$LAB_USER%$LAB_ADMIN_PASSWORD" \
|
||||
@@ -58,7 +63,15 @@ _web_sync() {
|
||||
>/dev/null 2>&1 || true
|
||||
|
||||
backend_ready fs01 300 || die "fs01 did not answer"
|
||||
backend_ps fs01 "Copy-Item -Path 'C:\\norbourg\\site\\*' -Destination 'C:\\inetpub\\wwwroot' -Recurse -Force; Test-Path 'C:\\inetpub\\wwwroot\\index.html'" \
|
||||
# Mirror, not merge: remove everything except the web.config that fs01.ps1
|
||||
# places in public/, otherwise files deleted from the repo keep being served.
|
||||
backend_ps fs01 "
|
||||
Get-ChildItem 'C:\inetpub\wwwroot' -Force | Where-Object { \$_.Name -ne 'public' } |
|
||||
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Get-ChildItem 'C:\inetpub\wwwroot\public' -Force | Where-Object { \$_.Name -ne 'web.config' } |
|
||||
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
|
||||
Copy-Item -Path 'C:\norbourg\site\*' -Destination 'C:\inetpub\wwwroot' -Recurse -Force
|
||||
Test-Path 'C:\inetpub\wwwroot\index.html'" \
|
||||
| grep -qi true || die "copy failed on fs01"
|
||||
|
||||
ok "site published to C:\\inetpub\\wwwroot"
|
||||
@@ -26,17 +26,21 @@ Commands:
|
||||
provision run the role stages (--role NAME for a single VM)
|
||||
web assemble the site; --sync publishes it to FS01
|
||||
snapshot freeze a clean baseline
|
||||
save snapshot --update then start (the closing step)
|
||||
reset revert to the baseline and start
|
||||
up, down start / stop the VMs
|
||||
status VM table
|
||||
vnc open a console on a VM
|
||||
doctor end-to-end health check
|
||||
kali install / start / stop the optional Kali attacker VM
|
||||
kali install / start / stop the attacker VM(s)
|
||||
answers print the instructor walkthrough
|
||||
destroy remove the VMs and generated artifacts
|
||||
EOF
|
||||
case $PLATFORM in
|
||||
proxmox) printf ' peers generate WireGuard configs for participants\n' ;;
|
||||
proxmox)
|
||||
printf ' users create a Proxmox account + console URL per participant\n'
|
||||
printf ' peers generate WireGuard configs for participants\n'
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
@@ -95,9 +99,11 @@ case $cmd in
|
||||
vnc) cmd_vnc "$@" ;;
|
||||
provision) cmd_provision "$@" ;;
|
||||
snapshot) cmd_snapshot "$@" ;;
|
||||
save) cmd_save "$@" ;;
|
||||
reset) cmd_reset "$@" ;;
|
||||
doctor) cmd_doctor "$@" ;;
|
||||
kali) cmd_kali "$@" ;;
|
||||
users) cmd_users "$@" ;;
|
||||
answers) cmd_answers "$@" ;;
|
||||
destroy) cmd_destroy "$@" ;;
|
||||
peers) cmd_peers "$@" ;;
|
||||
@@ -0,0 +1,181 @@
|
||||
#!/usr/bin/env python3
|
||||
"""bh_clues.py — BloodHound JSON reader for the Norbourg workshop lab.
|
||||
|
||||
bloodhound-python writes JSON for the BloodHound GUI, so a terminal user
|
||||
sees a successful collection and nothing else. This script answers the
|
||||
question a participant actually has: for one account, what can it touch?
|
||||
|
||||
It prints:
|
||||
* the account's SPNs and groups (including nested groups),
|
||||
* non-inherited ACEs held by the account or one of its groups,
|
||||
* local AdminTo / PSRemote / CanRDP / CanDCOM edges,
|
||||
and collapses GetChanges + GetChangesAll into a single DCSync line.
|
||||
|
||||
Written for the Norbourg lab (norbourg.lab). It only reads the JSON files
|
||||
produced by the collector; it never talks to the network.
|
||||
|
||||
Typical use:
|
||||
|
||||
bloodhound-python -d norbourg.lab -u svc_backup -p 'Backup2023!' \
|
||||
-ns 10.10.10.10 -c All
|
||||
python3 bh_clues.py svc_backup
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
INTERESTING = {
|
||||
"GenericAll", "GenericWrite", "WriteDacl", "WriteOwner", "Owns",
|
||||
"ForceChangePassword", "AddMember", "AddSelf", "AllExtendedRights",
|
||||
"DCSync", "AddKeyCredentialLink", "ReadLAPSPassword",
|
||||
"GetChanges", "GetChangesAll", "GetChangesInFilteredSet",
|
||||
}
|
||||
|
||||
LOCAL = (("LocalAdmins", "AdminTo"), ("PSRemoteUsers", "PSRemote"),
|
||||
("RemoteDesktopUsers", "CanRDP"), ("DcomUsers", "CanDCOM"))
|
||||
|
||||
|
||||
def load(directory: str, suffix: str) -> list[dict]:
|
||||
files = sorted(glob.glob(os.path.join(directory, f"*_{suffix}.json")))
|
||||
if not files:
|
||||
return []
|
||||
with open(files[-1], encoding="utf-8") as fh:
|
||||
return json.load(fh).get("data", [])
|
||||
|
||||
|
||||
def short(obj: dict) -> str:
|
||||
props = obj.get("Properties", {})
|
||||
name = (props.get("name") or "").split("@")[0]
|
||||
sam = props.get("samaccountname")
|
||||
return f"{name} ({sam})" if sam else name
|
||||
|
||||
|
||||
def parse_args(argv: list[str]) -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(
|
||||
prog="bh_clues.py",
|
||||
description=(
|
||||
"Print the BloodHound edges of one account from the collector's JSON. "
|
||||
"Built for the Norbourg workshop lab (norbourg.lab); it reads files only, "
|
||||
"no network access."
|
||||
),
|
||||
epilog=(
|
||||
"examples:\n"
|
||||
" bloodhound-python -d norbourg.lab -u svc_backup -p 'Backup2023!' "
|
||||
"-ns 10.10.10.10 -c All\n"
|
||||
" python3 bh_clues.py svc_backup\n"
|
||||
" python3 bh_clues.py svc_backup /tmp/collection\n"
|
||||
),
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
)
|
||||
parser.add_argument(
|
||||
"account",
|
||||
help="sAMAccountName to inspect (for example svc_backup or m.legault)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"directory",
|
||||
nargs="?",
|
||||
default=".",
|
||||
help="directory holding the *_users.json files (default: current directory)",
|
||||
)
|
||||
return parser.parse_args(argv)
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
args = parse_args(sys.argv[1:] if argv is None else argv)
|
||||
who = args.account.lower()
|
||||
directory = args.directory
|
||||
|
||||
users = load(directory, "users")
|
||||
groups = load(directory, "groups")
|
||||
computers = load(directory, "computers")
|
||||
extra = load(directory, "domains") + load(directory, "ous") + load(directory, "containers")
|
||||
|
||||
if not users:
|
||||
print(
|
||||
f"no *_users.json in {directory!r} — run bloodhound-python there first",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
|
||||
target = next(
|
||||
(u for u in users
|
||||
if (u.get("Properties", {}).get("samaccountname") or "").lower() == who
|
||||
or (u.get("Properties", {}).get("name") or "").split("@")[0].lower() == who),
|
||||
None,
|
||||
)
|
||||
if not target:
|
||||
print(
|
||||
f"account not found in this collection: {args.account}\n"
|
||||
"check the spelling, or collect again with -c All",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
|
||||
sid = target["ObjectIdentifier"]
|
||||
principals = {sid}
|
||||
changed = True
|
||||
while changed:
|
||||
changed = False
|
||||
for group in groups:
|
||||
gid = group["ObjectIdentifier"]
|
||||
if gid in principals:
|
||||
continue
|
||||
members = group.get("Members") or []
|
||||
if any(m.get("ObjectIdentifier") in principals for m in members):
|
||||
principals.add(gid)
|
||||
changed = True
|
||||
|
||||
print("\n# bh_clues.py — Norbourg lab (norbourg.lab)")
|
||||
print(f"# collection: {directory}")
|
||||
print(f"\n{short(target)}")
|
||||
for spn in target.get("Properties", {}).get("serviceprincipalnames") or []:
|
||||
print(f" SPN {spn}")
|
||||
for group in groups:
|
||||
if group["ObjectIdentifier"] in principals and group["ObjectIdentifier"] != sid:
|
||||
print(f" MemberOf {short(group)}")
|
||||
|
||||
rows: list[tuple[str, str]] = []
|
||||
for obj in users + groups + computers + extra:
|
||||
for ace in obj.get("Aces") or []:
|
||||
if ace.get("IsInherited"):
|
||||
continue
|
||||
if ace.get("PrincipalSID") not in principals:
|
||||
continue
|
||||
right = ace.get("RightName")
|
||||
if right not in INTERESTING:
|
||||
continue
|
||||
rows.append((right, short(obj)))
|
||||
|
||||
# The GUI shows a single DCSync edge; the JSON carries the two rights.
|
||||
for target_name in {t for r, t in rows if r in ("GetChanges", "GetChangesAll")}:
|
||||
rights = {r for r, t in rows if t == target_name and r in ("GetChanges", "GetChangesAll")}
|
||||
if {"GetChanges", "GetChangesAll"} <= rights:
|
||||
rows = [(r, t) for r, t in rows
|
||||
if not (t == target_name and r in ("GetChanges", "GetChangesAll"))]
|
||||
rows.append(("DCSync", target_name))
|
||||
|
||||
found = len(rows)
|
||||
for right, name in sorted(rows):
|
||||
print(f" {right:<18} -> {name}")
|
||||
|
||||
for computer in computers:
|
||||
for key, label in LOCAL:
|
||||
results = (computer.get(key) or {}).get("Results") or []
|
||||
if any(r.get("ObjectIdentifier") in principals for r in results):
|
||||
print(f" {label:<18} -> {short(computer)}")
|
||||
found += 1
|
||||
|
||||
if not found:
|
||||
print(" (no exploitable edge — this account is a dead end)")
|
||||
|
||||
print()
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,146 @@
|
||||
# Norbourg lab — first-boot bootstrap, runs once from the seed ISO.
|
||||
# The unattend file creates the account and triggers this; everything that
|
||||
# touches the network happens here because unattend TCPIP settings fail
|
||||
# silently when the adapter name does not match.
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$base = 'C:\norbourg'
|
||||
New-Item -ItemType Directory -Force -Path $base | Out-Null
|
||||
Start-Transcript -Path "$base\bootstrap.log" -Append | Out-Null
|
||||
|
||||
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
. (Join-Path $here 'config.ps1')
|
||||
|
||||
Write-Host "bootstrap: host=$($Config.Hostname) role=$($Config.Role) ip=$($Config.IP)"
|
||||
|
||||
# ------------------------------------------------------------------ network
|
||||
$nic = Get-NetAdapter |
|
||||
Where-Object { $_.Status -eq 'Up' -and $_.InterfaceDescription -notmatch 'Loopback' } |
|
||||
Select-Object -First 1
|
||||
|
||||
if (-not $nic) {
|
||||
Write-Host 'bootstrap: no up adapter, network step skipped'
|
||||
} else {
|
||||
Remove-NetIPAddress -InterfaceIndex $nic.ifIndex -Confirm:$false -ErrorAction SilentlyContinue
|
||||
Remove-NetRoute -InterfaceIndex $nic.ifIndex -Confirm:$false -ErrorAction SilentlyContinue
|
||||
|
||||
New-NetIPAddress -InterfaceIndex $nic.ifIndex `
|
||||
-IPAddress $Config.IP -PrefixLength $Config.Prefix `
|
||||
-DefaultGateway $Config.Gateway | Out-Null
|
||||
|
||||
Set-DnsClientServerAddress -InterfaceIndex $nic.ifIndex -ServerAddresses $Config.DNS
|
||||
Set-NetConnectionProfile -InterfaceIndex $nic.ifIndex -NetworkCategory Private -ErrorAction SilentlyContinue
|
||||
|
||||
# Cosmetic: silence the "make this PC discoverable" flyout that the IP
|
||||
# change re-triggers. New-Item -Force throws on this protected key, and a
|
||||
# Stop preference would abort the whole bootstrap — so it must not throw.
|
||||
try {
|
||||
New-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Network' `
|
||||
-Name NewNetworkWindowOff -Value 1 -PropertyType DWord -Force -ErrorAction Stop | Out-Null
|
||||
} catch {
|
||||
Write-Host "bootstrap: flyout tweak skipped ($($_.Exception.Message))"
|
||||
}
|
||||
|
||||
Write-Host "bootstrap: $($nic.Name) -> $($Config.IP)/$($Config.Prefix)"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------ WinRM
|
||||
# The host provisions over WinRM; no guest agent needed for that.
|
||||
Enable-PSRemoting -SkipNetworkProfileCheck -Force | Out-Null
|
||||
Set-NetFirewallRule -DisplayGroup 'Windows Remote Management' -Enabled True -Profile Any -ErrorAction SilentlyContinue
|
||||
|
||||
# SMB: the eval image leaves File and Printer Sharing disabled, which makes the
|
||||
# workstation invisible to a normal SMB scan.
|
||||
Enable-NetFirewallRule -DisplayGroup 'File and Printer Sharing' -ErrorAction SilentlyContinue
|
||||
|
||||
# ICMP echo: Windows drops it by default, and "ping the DC" is the first thing
|
||||
# anyone does. A lab where ping fails looks broken even when it is not.
|
||||
if (-not (Get-NetFirewallRule -DisplayName 'Norbourg ICMPv4' -ErrorAction SilentlyContinue)) {
|
||||
New-NetFirewallRule -DisplayName 'Norbourg ICMPv4' -Protocol ICMPv4 -IcmpType 8 `
|
||||
-Direction Inbound -Action Allow -Profile Any | Out-Null
|
||||
}
|
||||
|
||||
# QEMU guest agent. Proxmox provisions over `qm guest exec`, which needs it.
|
||||
# virtio-win is attached as a CD on that platform; on qemu it is absent and
|
||||
# this block does nothing.
|
||||
try {
|
||||
# Find the virtio CD by its content, not by volume label: the label is
|
||||
# not reliable across images and an empty one silently skipped the whole
|
||||
# block (no driver, no agent, no provisioning).
|
||||
$virtioRoot = $null
|
||||
foreach ($drv in (Get-PSDrive -PSProvider FileSystem -ErrorAction SilentlyContinue)) {
|
||||
if (Test-Path "$($drv.Root)guest-agent\qemu-ga-x86_64.msi") {
|
||||
$virtioRoot = $drv.Root
|
||||
break
|
||||
}
|
||||
}
|
||||
if ($virtioRoot) {
|
||||
# The agent MSI does not install the VirtIO serial driver. Without it
|
||||
# the service starts but never connects to the channel, and Proxmox
|
||||
# shows "guest agent is not running", which blocks provisioning.
|
||||
# Pick the driver for this Windows build first (2k12 first in the
|
||||
# directory made pnputil reject it on Server 2022), then fall back to
|
||||
# the other amd64 builds until one reports success.
|
||||
$build = [Environment]::OSVersion.Version.Build
|
||||
$pref = '2k12'
|
||||
if ($build -ge 26100) { $pref = '2k25' } elseif ($build -ge 20348) { $pref = '2k22' } elseif ($build -ge 17763) { $pref = '2k19' } elseif ($build -ge 14393) { $pref = '2k16' }
|
||||
$candidates = @($pref, '2k25', '2k22', 'w11', '2k19', '2k16', '2k12') |
|
||||
Select-Object -Unique
|
||||
$driverOk = $false
|
||||
foreach ($v in $candidates) {
|
||||
$inf = Join-Path $virtioRoot "vioserial\$v\amd64\vioser.inf"
|
||||
if (-not (Test-Path $inf)) { continue }
|
||||
$null = pnputil.exe /add-driver $inf /install
|
||||
Write-Host "bootstrap: vioser $v exit=$LASTEXITCODE"
|
||||
if ($LASTEXITCODE -eq 0) { $driverOk = $true; break }
|
||||
}
|
||||
if (-not $driverOk) {
|
||||
Write-Host 'bootstrap: no vioser driver could be installed'
|
||||
}
|
||||
|
||||
$msi = "$($virtioRoot)guest-agent\qemu-ga-x86_64.msi"
|
||||
if (Test-Path $msi) {
|
||||
$proc = Start-Process msiexec.exe -ArgumentList "/i `"$msi`" /qn /norestart" -Wait -PassThru
|
||||
Write-Host "bootstrap: qemu-ga msi exit=$($proc.ExitCode)"
|
||||
Set-Service -Name QEMU-GA -StartupType Automatic -ErrorAction SilentlyContinue
|
||||
Start-Service -Name QEMU-GA -ErrorAction SilentlyContinue
|
||||
Write-Host 'bootstrap: qemu guest agent installed'
|
||||
} else {
|
||||
Write-Host 'bootstrap: virtio-win mounted but qemu-ga msi not found'
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
Write-Host "bootstrap: guest agent step skipped ($($_.Exception.Message))"
|
||||
}
|
||||
|
||||
# RDP: useful for the instructor when a step misbehaves. This only opens the
|
||||
# listener; who may log on is still governed by Remote Desktop Users.
|
||||
try {
|
||||
Set-ItemProperty 'HKLM:\System\CurrentControlSet\Control\Terminal Server' `
|
||||
-Name fDenyTSConnections -Value 0 -ErrorAction Stop
|
||||
Set-Service -Name TermService -StartupType Automatic -ErrorAction SilentlyContinue
|
||||
Start-Service -Name TermService -ErrorAction SilentlyContinue
|
||||
Enable-NetFirewallRule -DisplayGroup 'Remote Desktop' -ErrorAction SilentlyContinue
|
||||
Write-Host 'bootstrap: RDP enabled'
|
||||
} catch {
|
||||
Write-Host "bootstrap: RDP setup failed ($($_.Exception.Message))"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------ marker
|
||||
"$env:COMPUTERNAME|$($Config.Role)|$($Config.IP)|$((Get-Date).ToString('s'))" |
|
||||
Set-Content -Path "$base\stamp.txt" -Encoding ascii
|
||||
|
||||
# ------------------------------------------------------------------ role
|
||||
# The role stages are driven by the host (`./lab.sh provision`), which orders
|
||||
# them: the DC must be promoted before a member tries to join. Running them
|
||||
# here as well made every guest race the harness — fs01 joined before the
|
||||
# domain existed, and dc01 ran two promotions at once.
|
||||
$role = Join-Path $here "roles\$($Config.Role).ps1"
|
||||
if (Test-Path $role) {
|
||||
Write-Host "bootstrap: role $($Config.Role) staged, waiting for ./lab.sh provision"
|
||||
} else {
|
||||
Write-Host "bootstrap: no role script for '$($Config.Role)' yet (phase 5)"
|
||||
}
|
||||
|
||||
Write-Host 'bootstrap: done'
|
||||
Stop-Transcript | Out-Null
|
||||
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 848 B After Width: | Height: | Size: 848 B |
|
Before Width: | Height: | Size: 457 B After Width: | Height: | Size: 457 B |
|
Before Width: | Height: | Size: 48 B After Width: | Height: | Size: 48 B |
|
Before Width: | Height: | Size: 551 B After Width: | Height: | Size: 551 B |
|
Before Width: | Height: | Size: 496 B After Width: | Height: | Size: 496 B |
|
Before Width: | Height: | Size: 172 B After Width: | Height: | Size: 172 B |
|
Before Width: | Height: | Size: 151 B After Width: | Height: | Size: 151 B |
|
Before Width: | Height: | Size: 439 B After Width: | Height: | Size: 439 B |
|
Before Width: | Height: | Size: 352 B After Width: | Height: | Size: 352 B |
|
Before Width: | Height: | Size: 51 B After Width: | Height: | Size: 51 B |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 51 B After Width: | Height: | Size: 51 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 538 B After Width: | Height: | Size: 538 B |
|
Before Width: | Height: | Size: 724 B After Width: | Height: | Size: 724 B |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.9 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 814 B After Width: | Height: | Size: 814 B |
|
Before Width: | Height: | Size: 859 B After Width: | Height: | Size: 859 B |
|
Before Width: | Height: | Size: 51 B After Width: | Height: | Size: 51 B |
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 743 B After Width: | Height: | Size: 743 B |
|
Before Width: | Height: | Size: 372 B After Width: | Height: | Size: 372 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 51 B After Width: | Height: | Size: 51 B |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 51 B After Width: | Height: | Size: 51 B |