Split into qemu and proxmox platforms over a shared content tree

platforms/qemu and platforms/proxmox each have their own lab.sh and
lab.conf; content/ holds everything shared (roles, seed, site, helpers).
The dispatcher, preflight and command implementations are common and take
platform differences from the backend.

Proxmox backend: qm create with q35/SATA/e1000, ISOs and seed ISOs in an
ISO storage, provisioning over qm guest exec (no Python packages needed on
the host), template + clone for reset, and peers/ to emit WireGuard configs.
The role scripts now ride on the seed ISO, so provisioning transfers nothing.

build-bundle.sh produces a self-contained tarball per platform, for hosts
that cannot reach the git server.

Both configs are generic: no absolute path from this machine remains.
This commit is contained in:
2026-10-22 19:23:16 -04:00
parent 538fb9a117
commit 890dd58700
349 changed files with 1142 additions and 2236 deletions
+3 -2
View File
@@ -3,12 +3,13 @@ answers/
lab.conf.local
# artefacts générés / volumineux
dist/
*.iso
*.qcow2
*.vmdk
*.ova
web/site/
seed/out/
content/web/site/
content/seed/out/
run/
logs/
+89 -63
View File
@@ -1,113 +1,139 @@
# Laboratoire Norbourg — atelier d'introduction au pentest de domaine
> **État : fonctionnel.** Le laboratoire se déploie, se réinitialise en deux minutes et le
> parcours complet (site → SMB → Kerberoasting → WinRM → ACL → Domain Admin) a été validé.
Laboratoire Active Directory isolé, déployé par script, pour initier des collègues au pentest de
domaine. L'objectif de l'atelier : partir d'un accès anonyme et obtenir les droits de
**Domain Admin**, comme sur une plateforme de type Hack The Box.
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.
## En bref
> **É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.
| | |
|---|---|
| Domaine | `norbourg.lab` (NetBIOS `NORBOURG`) |
| Sous-réseau du labo | `10.10.10.0/24`, isolé du réseau de bureau |
| Site Web | site Norbourg de 2002, archivé, servi par FS01 |
| Accès des participants | Kali sur `192.168.10.0/24`, routé vers le labo |
| Postes | DC01, FS01, WS01 (+ WS02 et routeur sur Proxmox) |
## Deux plateformes, un même contenu
## Topologie visée
| | `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` | VM routeur WireGuard |
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
```
Kali (192.168.10.x)
│ route 10.10.10.0/24 via 192.168.10.230 · DNS 10.10.10.10
participant (Kali)
│ route 10.10.10.0/24 via 10.10.10.1 (ou tunnel WireGuard)
▼
hôte 192.168.10.230 (pont br-lab, pare-feu : entrant seulement)
│
br-lab 10.10.10.230
├── 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
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
- Un hôte Linux avec KVM (`/dev/kvm` accessible), 16 Go de RAM et une centaine de Go libres.
- Un accès `sudo` **une seule fois**, pour créer le pont réseau et la politique de pare-feu.
- Une machine Kali sur le même réseau local que l'hôte.
- 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.
## Mise en route
---
## Démarrage — plateforme `qemu` (Linux générique)
```bash
./lab.sh check # valide hôte, stockage, réseau et configuration
./lab.sh init # arborescence de stockage (chattr +C sur btrfs)
./lab.sh isos # télécharge 5,6 Go d'images Windows (une fois)
sudo ./scripts/setup-network.sh # pont br-lab et isolation — la seule commande root
cd platforms/qemu
./lab.sh check # valide hôte, stockage, réseau, configuration
./lab.sh init # arborescence + chattr +C
sudo ./scripts/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 (devient la base de reset)
./lab.sh snapshot # fige l'état propre
```
Le laboratoire est prêt. Vérification :
## 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
./lab.sh status # VM, IP, état, console VNC
./lab.sh doctor # pont, SMB/WinRM, DNS, site, partage
./lab.sh vnc dc01 # console graphique d'une VM
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
```
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/
```
## Commandes
| Commande | Effet |
|---|---|
| `check` | préflight : refuse de continuer si le stockage est inadapté |
| `init` | crée l'arborescence, désactive le CoW btrfs sur les disques |
| `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 |
| `build` | disques + installation sans intervention, attente de WinRM |
| `provision [--role NAME]` | domaine, comptes, ACL, partage, drapeaux |
| `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 propre ; `--update` y intègre les changements |
| `up` / `down` | démarre (DC d'abord) / arrête proprement |
| `reset` | jette les disques de travail et repart de la base (~2 min) |
| `status` | tableau des VM |
| `doctor` | bilan de santé de bout en bout |
| `vnc <vm>` | console graphique |
`build --dry-run` affiche les commandes QEMU sans rien créer.
| `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 |
|---|---|
| `lab.sh` | point d'entrée, une commande par étape |
| `lab.conf` | toute la configuration (réseau, stockage, liste des VM) |
| `lib/` | commandes communes et vérifications |
| `backends/` | `qemu` (local) et `proxmox` (production) |
| `seed/` | fichiers de réponse Windows et fabrication des ISO d'amorçage |
| `windows/roles/` | scripts PowerShell par machine (à venir) |
| `site-src/` | site Norbourg 2002 : miroir, images retouchées, scripts d'origine |
| `web/` | site assemblé pour FS01, fichiers pièges |
| `docs/` | documentation de l'atelier (à venir) |
| `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 `br-lab` n'a aucun port vers l'extérieur ;
- le pare-feu de l'hôte n'autorise que le **sens Kali → labo**, sur les ports nécessaires
- 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 labo → bureau est rejeté.
- le sens laboratoire → bureau est rejeté.
Cette isolation est vérifiée à la phase 2, dans les deux sens.
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é
`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.
`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
-7
View File
@@ -1,7 +0,0 @@
# shellcheck shell=bash
# Proxmox VE backend — production target (phase 11).
# Mirrors the qemu backend's interface; everything here is still a stub.
backend_check() {
_c_warn "proxmox backend not implemented yet (phase 11)"
}
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
# build-bundle.sh — produce a self-contained tarball for one platform.
#
# ./build-bundle.sh both platforms
# ./build-bundle.sh proxmox only the Proxmox bundle
# ./build-bundle.sh qemu /tmp/out custom output directory
#
# The bundle carries the shared content, the platform entrypoint, the docs and
# the answer key, so it can be copied to a host that cannot reach the git
# server: scp norbourg-proxmox.tar.gz root@pve:/root/ && tar xzf ...
set -euo pipefail
ROOT=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd -P)
TARGET=${1:-all}
OUT=${2:-$ROOT/dist}
info() { printf '[*] %s\n' "$*"; }
ok() { printf '[ok] %s\n' "$*"; }
build() {
local platform=$1
local stage="$OUT/norbourg-$platform"
local archive="$OUT/norbourg-$platform.tar.gz"
[[ -d $ROOT/platforms/$platform ]] || { echo "no such platform: $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 - \
--exclude='.git' \
--exclude='__pycache__' \
--exclude='*.pyc' \
--exclude='content/web/site' \
--exclude='content/seed/out' \
--exclude='dist' \
content "platforms/$platform" docs answers README.md \
| tar -C "$stage" -xf -
# Trim the platform directories we did not ask for.
find "$stage/platforms" -mindepth 1 -maxdepth 1 -type d ! -name "$platform" -exec rm -rf {} +
tar -C "$OUT" -czf "$archive" "norbourg-$platform"
ok "$archive ($(du -h "$archive" | cut -f1))"
}
mkdir -p "$OUT"
case $TARGET in
all)
build qemu
build proxmox
;;
qemu|proxmox)
build "$TARGET"
;;
*)
echo "usage: $0 [qemu|proxmox|all] [output-dir]" >&2
exit 2
;;
esac
printf '\n'
info "copy to the target host, then:"
info " tar xzf norbourg-<platform>.tar.gz && cd norbourg-<platform>"
info " ./platforms/<platform>/lab.sh check"
+41 -23
View File
@@ -11,6 +11,11 @@ _c_warn() { warn "$*"; CHECK_WARNS=$(( CHECK_WARNS + 1 )); }
_c_fail() { fail "$*"; CHECK_FAILS=$(( CHECK_FAILS + 1 )); }
cmd_check() {
local arg
for arg in "$@"; do
[[ $arg == --strict ]] && STRICT=1
done
CHECK_FAILS=0
CHECK_WARNS=0
@@ -21,9 +26,9 @@ cmd_check() {
fi
step "host"
info " ${os_pretty} · $(nproc) threads · kernel $(uname -r)"
info " ${os_pretty} · $(nproc) threads · kernel $(uname -r) · ${PLATFORM:-qemu} platform"
_check_commands
_check_kvm
[[ ${PLATFORM:-qemu} == qemu ]] && _check_kvm
_check_ram
step "storage"
@@ -50,7 +55,13 @@ cmd_check() {
_check_commands() {
local missing=() cmd
for cmd in qemu-system-x86_64 qemu-img socat python3 curl; do
local needed
if [[ ${PLATFORM:-qemu} == proxmox ]]; then
needed=(qm pvesm python3 curl)
else
needed=(qemu-system-x86_64 qemu-img socat python3 curl)
fi
for cmd in "${needed[@]}"; do
have_cmd "$cmd" || missing+=("$cmd")
done
if (( ${#missing[@]} > 0 )); then
@@ -126,13 +137,15 @@ _check_storage() {
_c_ok "disk: ${free} GB free, ${need_gb} GB projected"
fi
if is_mounted "$LAB_ISO_CACHE"; then
_c_ok "ISO cache mounted: $(mountpoint_of "$LAB_ISO_CACHE")"
else
_c_warn "ISO cache parent $(dirname "$LAB_ISO_CACHE") is not a mount point"
if [[ ${PLATFORM:-qemu} == qemu ]]; then
if is_mounted "$LAB_ISO_CACHE"; then
_c_ok "ISO cache mounted: $(mountpoint_of "$LAB_ISO_CACHE")"
else
_c_warn "ISO cache parent $(dirname "$LAB_ISO_CACHE") is not a mount point"
fi
fi
if [[ $ft == btrfs ]]; then
if [[ ${PLATFORM:-qemu} == qemu && $ft == btrfs ]]; then
if [[ -d $LAB_ROOT/images ]] && lsattr -d "$LAB_ROOT/images" 2>/dev/null | awk '{print $1}' | grep -q 'C'; then
_c_ok "images/ has +C (CoW disabled)"
else
@@ -144,22 +157,28 @@ _check_storage() {
_check_network() {
local addrs
if ip link show "$BRIDGE" >/dev/null 2>&1; then
_c_ok "bridge ${BRIDGE} exists"
if ip link show "$LAB_BRIDGE" >/dev/null 2>&1; then
_c_ok "bridge ${LAB_BRIDGE} exists"
else
_c_warn "bridge ${BRIDGE} missing: run sudo ./scripts/setup-network.sh"
if [[ ${PLATFORM:-qemu} == proxmox ]]; then
_c_warn "bridge ${LAB_BRIDGE} missing: create it in the Proxmox GUI"
else
_c_warn "bridge ${LAB_BRIDGE} missing: run sudo ./scripts/setup-network.sh"
fi
fi
if [[ -r /etc/qemu/bridge.conf ]] && grep -qx "allow ${BRIDGE}" /etc/qemu/bridge.conf; then
_c_ok "qemu-bridge-helper allows ${BRIDGE}"
else
_c_warn "/etc/qemu/bridge.conf does not allow ${BRIDGE}"
fi
if [[ ${PLATFORM:-qemu} == qemu ]]; then
if [[ -r /etc/qemu/bridge.conf ]] && grep -qx "allow ${LAB_BRIDGE}" /etc/qemu/bridge.conf; then
_c_ok "qemu-bridge-helper allows ${LAB_BRIDGE}"
else
_c_warn "/etc/qemu/bridge.conf does not allow ${LAB_BRIDGE}"
fi
if [[ $(sysctl -n net.ipv4.ip_forward 2>/dev/null) == 1 ]]; then
_c_ok "ip_forward enabled"
else
_c_warn "ip_forward disabled"
if [[ $(sysctl -n net.ipv4.ip_forward 2>/dev/null) == 1 ]]; then
_c_ok "ip_forward enabled"
else
_c_warn "ip_forward disabled"
fi
fi
addrs=$(ip -4 -o addr show scope global 2>/dev/null | awk '{ printf "%s=%s ", $2, $4 }')
@@ -188,8 +207,7 @@ _check_config() {
_check_backend() {
case $BACKEND in
qemu) backend_check ;;
proxmox) _c_warn "proxmox backend is still a stub (phase 11)" ;;
*) _c_fail "unknown backend: ${BACKEND}" ;;
qemu|proxmox) backend_check ;;
*) _c_fail "unknown backend: ${BACKEND}" ;;
esac
}
+23 -23
View File
@@ -1,9 +1,9 @@
# shellcheck shell=bash
# cmd_doctor — end-to-end health check of the running laboratory.
_c_ok() { ok "$*"; }
_c_warn() { warn "$*"; DOCTOR_WARNS=$(( DOCTOR_WARNS + 1 )); }
_c_fail() { fail "$*"; DOCTOR_FAILS=$(( DOCTOR_FAILS + 1 )); }
_d_ok() { ok "$*"; }
_d_warn() { warn "$*"; DOCTOR_WARNS=$(( DOCTOR_WARNS + 1 )); }
_d_fail() { fail "$*"; DOCTOR_FAILS=$(( DOCTOR_FAILS + 1 )); }
cmd_doctor() {
DOCTOR_FAILS=0
@@ -11,10 +11,10 @@ cmd_doctor() {
local i name ip
step "host"
if ip link show "$BRIDGE" >/dev/null 2>&1; then
_c_ok "bridge ${BRIDGE} present"
if ip link show "$LAB_BRIDGE" >/dev/null 2>&1; then
_d_ok "bridge ${LAB_BRIDGE} present"
else
_c_fail "bridge ${BRIDGE} missing — run sudo ./scripts/setup-network.sh"
_d_fail "bridge ${LAB_BRIDGE} missing — run sudo ./scripts/setup-network.sh"
fi
step "machines"
@@ -23,21 +23,21 @@ cmd_doctor() {
ip=${VM_IPS[$i]}
if ! backend_running "$name"; then
_c_fail "$name is not running — ./lab.sh up"
_d_fail "$name is not running — ./lab.sh up"
continue
fi
if tcp_open "$ip" 445; then
_c_ok "$(printf '%-6s %-14s smb up' "$name" "$ip")"
_d_ok "$(printf '%-6s %-14s smb up' "$name" "$ip")"
else
_c_warn "$(printf '%-6s %-14s smb not answering' "$name" "$ip")"
_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
_c_ok "$(printf '%-6s %-14s winrm up' "$name" "$ip")"
_d_ok "$(printf '%-6s %-14s winrm up' "$name" "$ip")"
else
_c_warn "$(printf '%-6s %-14s winrm not answering' "$name" "$ip")"
_d_warn "$(printf '%-6s %-14s winrm not answering' "$name" "$ip")"
fi
fi
done
@@ -47,46 +47,46 @@ cmd_doctor() {
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
_c_ok "dns: www.norbourg.lab -> $www"
_d_ok "dns: www.norbourg.lab -> $www"
else
_c_fail "dns: www.norbourg.lab did not resolve via ${LAB_DC_IP} (got '${www:-nothing}')"
_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
_c_ok "dns: ldap SRV record present"
_d_ok "dns: ldap SRV record present"
else
_c_fail "dns: ldap SRV record missing — AD discovery would fail"
_d_fail "dns: ldap SRV record missing — AD discovery would fail"
fi
else
_c_warn "dig not installed, DNS checks skipped"
_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
_c_ok "site answers on 10.10.10.20"
_d_ok "site answers on 10.10.10.20"
else
_c_fail "site not answering (${code:-timeout}) — ./lab.sh web --sync"
_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
_c_ok "entry point reachable: /public/IT-inventaire.txt"
_d_ok "entry point reachable: /public/IT-inventaire.txt"
else
_c_fail "entry point missing (${code:-timeout})"
_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
_c_ok "Public share reachable with the leaked credential"
_d_ok "Public share reachable with the leaked credential"
else
_c_warn "Public share not readable as helpdesk1 (domain channel or DNS?)"
_d_warn "Public share not readable as helpdesk1 (domain channel or DNS?)"
fi
else
_c_warn "smbclient not installed, share check skipped"
_d_warn "smbclient not installed, share check skipped"
fi
printf '\n'
+33
View File
@@ -0,0 +1,33 @@
# shellcheck shell=bash
# cmd_answers / cmd_destroy — small utilities shared by both platforms.
cmd_answers() {
local file="$ROOT_DIR/answers/walkthrough.md"
[[ -r $file ]] || die "no answer key at $file"
cat "$file"
}
cmd_destroy() {
local name i
step "stop"
for name in "${VM_NAMES[@]}"; do
backend_stop "$name" >/dev/null 2>&1 || true
done
step "remove"
for name in "${VM_NAMES[@]}"; do
backend_destroy "$name" || warn "could not fully remove $name"
done
step "generated artifacts"
rm -rf "$LAB_ROOT/seeds" "$LAB_ROOT/run" "$LAB_ROOT/provision"
ok "seed ISOs, runtime state and provisioning scratch removed"
printf '\n'
info "kept: ${LAB_ROOT}/images (baselines), logs, and the ISO cache"
info "remove those by hand if you really want the space back"
}
# Platforms that support participant tunnels override this.
cmd_peers() { planned peers; }
+61
View File
@@ -0,0 +1,61 @@
# shellcheck shell=bash
# cmd_provision — run the role stages inside each guest.
#
# The role scripts travel on the seed ISO and bootstrap copies them to
# C:\norbourg, so provisioning never transfers files: it only asks the guest
# to run a script and waits for its .done marker. The transport (WinRM or the
# QEMU guest agent) lives in the backend.
cmd_provision() {
local only=""
while (( $# > 0 )); do
case $1 in
--role) only=$2; shift 2 ;;
-h|--help) info "usage: ./lab.sh provision [--role NAME]"; return 0 ;;
*) die "unknown argument: $1" ;;
esac
done
: "${LAB_SAFE_MODE_PASSWORD:?LAB_SAFE_MODE_PASSWORD is not set in lab.conf}"
local i name role script marker
for i in "${!VM_NAMES[@]}"; do
name=${VM_NAMES[$i]}
role=${VM_ROLES[$i]}
script="C:\\norbourg\\roles\\${role}.ps1"
[[ -n $only && $only != "$name" && $only != "$role" ]] && continue
step "$name ($role)"
if [[ $role != dc01 ]]; then
backend_ready dc01 300 || die "dc01 is not reachable — provision dc01 first"
fi
backend_ready "$name" 600 || { fail "$name: guest agent/WinRM unreachable"; return 1; }
backend_start "$name" "$script" || die "$name: could not start ${role}.ps1"
marker=$(backend_wait "$name" "$script" 3600) || {
fail "$name: ${role}.ps1 did not finish"
return 1
}
[[ $marker == FAIL* ]] && { fail "$name: ${role}.ps1 failed — $marker"; return 1; }
ok "$name: $marker"
if [[ -f $CONTENT_DIR/windows/roles/${role}-post.ps1 ]]; then
info " waiting for the guest to come back"
backend_ready "$name" 900 || { fail "$name: did not come back after reboot"; return 1; }
script="C:\\norbourg\\roles\\${role}-post.ps1"
backend_start "$name" "$script" || { fail "$name: could not start the post stage"; return 1; }
marker=$(backend_wait "$name" "$script" 3600) || {
fail "$name: ${role}-post.ps1 did not finish"
return 1
}
[[ $marker == FAIL* ]] && { fail "$name: ${role}-post.ps1 failed — $marker"; return 1; }
ok "$name: $marker"
fi
done
printf '\n'
ok "provisioning complete"
}
+15 -6
View File
@@ -3,15 +3,15 @@
# Nothing here needs root or a downloaded ISO; it is pure file assembly.
cmd_seeds() {
local tmpl="$LAB_DIR/seed/Autounattend.xml.tmpl"
local payload="$LAB_DIR/seed/payload"
local tmpl="$CONTENT_DIR/seed/Autounattend.xml.tmpl"
local payload="$CONTENT_DIR/seed/payload"
[[ -r $tmpl ]] || die "missing template: $tmpl"
[[ -d $payload ]] || die "missing payload dir: $payload"
have_cmd genisoimage || have_cmd xorriso || die "genisoimage or xorriso is required"
: "${LAB_ADMIN_PASSWORD:?LAB_ADMIN_PASSWORD is not set in lab.conf}"
mkdir -p "$LAB_ROOT/seeds"
mkdir -p "$SEED_DIR"
local i name ip role work iso volid dns
for i in "${!VM_NAMES[@]}"; do
@@ -20,7 +20,7 @@ cmd_seeds() {
role=${VM_ROLES[$i]}
dns=$LAB_DC_IP # every lab VM resolves through the DC
work="$LAB_ROOT/seeds/$name"
work="$SEED_DIR/$name"
rm -rf "$work"
mkdir -p "$work/norbourg/roles"
@@ -32,6 +32,15 @@ cmd_seeds() {
cp "$payload/bootstrap.cmd" "$work/norbourg/"
cp "$payload/bootstrap.ps1" "$work/norbourg/"
# Ship the role scripts on the ISO so the guest never needs a file
# transfer: bootstrap copies this tree to C:\norbourg and runs from there.
mkdir -p "$work/norbourg/lib" "$work/norbourg/roles"
cp "$CONTENT_DIR/windows/lib/common.ps1" "$work/norbourg/lib/"
render_role "$CONTENT_DIR/windows/roles/${role}.ps1" "$work/norbourg/roles/${role}.ps1"
if [[ -f $CONTENT_DIR/windows/roles/${role}-post.ps1 ]]; then
render_role "$CONTENT_DIR/windows/roles/${role}-post.ps1" "$work/norbourg/roles/${role}-post.ps1"
fi
cat > "$work/norbourg/config.ps1" <<EOF
\$Config = @{
Hostname = '${name}'
@@ -50,7 +59,7 @@ import sys, xml.etree.ElementTree as ET
ET.parse(sys.argv[1])
PY
iso="$LAB_ROOT/seeds/${name}-seed.iso"
iso="$SEED_DIR/${name}-seed.iso"
volid="NRBG_${name^^}"
if have_cmd genisoimage; then
genisoimage -quiet -volid "$volid" -J -R -o "$iso" "$work"
@@ -62,5 +71,5 @@ PY
done
printf '\n'
ok "${#VM_NAMES[@]} seed ISO(s) in ${LAB_ROOT}/seeds"
ok "${#VM_NAMES[@]} seed ISO(s) in ${SEED_DIR}"
}
+4 -4
View File
@@ -3,7 +3,7 @@
# Syncing to FS01 arrives with phase 7, once the VM exists.
cmd_web() {
local site="$LAB_DIR/web/site" seed="$LAB_DIR/web/seed"
local site="$CONTENT_DIR/web/site" seed="$CONTENT_DIR/web/seed"
local sync=0 arg
for arg in "$@"; do
case $arg in
@@ -14,7 +14,7 @@ cmd_web() {
done
step "assemble"
python3 "$LAB_DIR/scripts/prepare_site.py" || die "site assembly failed"
python3 "$CONTENT_DIR/scripts/prepare_site.py" || die "site assembly failed"
step "seed layer"
[[ -d $seed ]] || die "missing $seed"
@@ -31,8 +31,8 @@ cmd_web() {
if (( ! sync )); then
printf '\n'
ok "web root ready: ${site#$LAB_DIR/}"
info " preview: python3 -m http.server 8080 --directory ${site#$LAB_DIR/}"
ok "web root ready: ${site#$CONTENT_DIR/}"
info " preview: python3 -m http.server 8080 --directory ${site#$CONTENT_DIR/}"
info " push to FS01: ./lab.sh web --sync"
return 0
fi
+26 -1
View File
@@ -23,6 +23,27 @@ die() { fail "$*"; exit 1; }
step() { printf '\n%s==> %s%s\n' "$C_BLUE" "$*" "$C_RESET"; }
detail() { if (( VERBOSE )); then printf '%s %s%s\n' "$C_DIM" "$*" "$C_RESET"; fi; return 0; }
# Substitute the lab-wide tokens in a role script.
render_role() {
local src=$1 dst=$2
sed -e "s|@@DOMAIN@@|${DOMAIN}|g" \
-e "s|@@NETBIOS@@|${NETBIOS}|g" \
-e "s|@@BASE_DN@@|${BASE_DN}|g" \
-e "s|@@ADMIN_PASSWORD@@|${LAB_ADMIN_PASSWORD}|g" \
-e "s|@@SAFE_MODE_PASSWORD@@|${LAB_SAFE_MODE_PASSWORD}|g" \
"$src" > "$dst"
}
# Deterministic MAC from the last two octets: 10.10.10.31 -> 52:54:00:0a:1f:00
# (six octets — a five-byte value is rejected as "invalid ethernet address")
qemu_mac_for() {
local ip=$1
local b3=${ip##*.}
local rest=${ip%.*}
local b2=${rest##*.}
printf '52:54:00:%02x:%02x:00' "$b2" "$b3"
}
# ------------------------------------------------------------------ commands
have_cmd() { command -v "$1" >/dev/null 2>&1; }
@@ -50,11 +71,15 @@ load_config() {
: "${LAB_ROOT:?LAB_ROOT is not set}"
: "${LAB_ISO_CACHE:?LAB_ISO_CACHE is not set}"
: "${BRIDGE:?BRIDGE is not set}"
: "${LAB_PREFIX:?LAB_PREFIX is not set}"
BACKEND=${BACKEND:-qemu}
BASE_DN="DC=${DOMAIN%%.*},DC=${DOMAIN#*.}"
# Each platform names its bridge differently (br-lab / vmbr10).
LAB_BRIDGE=${LAB_BRIDGE:-${BRIDGE:-${PVE_BRIDGE:-}}}
: "${LAB_BRIDGE:?no lab bridge configured (BRIDGE or PVE_BRIDGE)}"
MIN_FREE_GB=${MIN_FREE_GB:-20}
SEED_DIR=${SEED_DIR:-$LAB_ROOT/seeds}
DISK_FILL_RATIO=${DISK_FILL_RATIO:-60}
ISO_BUDGET_GB=${ISO_BUDGET_GB:-8}
+103
View File
@@ -0,0 +1,103 @@
# shellcheck shell=bash
# Shared command dispatcher. Sourced by each platform's lab.sh after the
# command implementations and before anything runs.
#
# The platform provides: LAB_DIR, CONTENT_DIR, PLATFORM, and its backend file
# at $LAB_DIR/backends/<PLATFORM>.sh.
usage() {
cat <<EOF
Norbourg lab ${LAB_SH_VERSION} — ${PLATFORM} platform
Usage: ./lab.sh [options] <command>
Options:
--strict treat check warnings as failures
-v, --verbose extra detail
-h, --help this text
--version print the version
Commands:
check preflight: host, storage, network, configuration
init create the storage layout and the runtime venv if needed
isos download the Windows media
seeds render unattend files and pack the seed ISOs
build create the VMs and run the unattended installs
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
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
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' ;;
esac
}
planned() {
warn "'$1' is not implemented on this platform"
return 3
}
# ------------------------------------------------------------------ arguments
cmd=""
while (( $# > 0 )); do
case $1 in
--strict) STRICT=1; shift ;;
-v|--verbose) VERBOSE=1; shift ;;
-h|--help|help) usage; exit 0 ;;
--version) printf '%s\n' "$LAB_SH_VERSION"; exit 0 ;;
--) shift; break ;;
-*)
# Before the command this is a typo; after it, the flag belongs to the verb.
[[ -z $cmd ]] && die "unknown option: $1 (try --help)"
break
;;
*)
# First positional is the command; everything after it belongs to the verb
# (peers wants a list of names, provision wants --role NAME).
if [[ -z $cmd ]]; then cmd=$1; shift; fi
break
;;
esac
done
if [[ -z $cmd ]]; then
usage
exit 2
fi
load_config
backend_file="$LAB_DIR/backends/${BACKEND}.sh"
[[ -r $backend_file ]] || die "no backend '${BACKEND}' for the ${PLATFORM} platform (looked for ${backend_file})"
# shellcheck disable=SC1090
source "$backend_file"
# ------------------------------------------------------------------ dispatch
case $cmd in
check) cmd_check "$@" || exit $? ;;
init) cmd_init "$@" ;;
isos) cmd_isos "$@" ;;
seeds) cmd_seeds "$@" ;;
web) cmd_web "$@" ;;
build) cmd_build "$@" ;;
up) cmd_up "$@" ;;
down) cmd_down "$@" ;;
status) cmd_status "$@" ;;
vnc) cmd_vnc "$@" ;;
provision) cmd_provision "$@" ;;
snapshot) cmd_snapshot "$@" ;;
reset) cmd_reset "$@" ;;
doctor) cmd_doctor "$@" ;;
answers) cmd_answers "$@" ;;
destroy) cmd_destroy "$@" ;;
peers) cmd_peers "$@" ;;
*) die "unknown command: ${cmd} (try --help)" ;;
esac
@@ -22,10 +22,11 @@ import shutil
import sys
from pathlib import Path
REPO = Path(__file__).resolve().parent.parent
SRC_MIRROR = REPO / "site-src" / "norbourg-2002"
SRC_HOME = REPO / "site-src" / "norbourg-static"
OUT = REPO / "web" / "site"
CONTENT = Path(__file__).resolve().parent.parent
REPO = CONTENT.parent
SRC_MIRROR = CONTENT / "site-src" / "norbourg-2002"
SRC_HOME = CONTENT / "site-src" / "norbourg-static"
OUT = CONTENT / "web" / "site"
# Files that exist only for the archivist.
DROP_FILES = {"MIRROR.txt", "_index.json"}
+7
View File
@@ -0,0 +1,7 @@
@echo off
rem Norbourg lab — first-logon entry point (runs from the seed ISO).
rem The ISO carries the whole payload, so copy it locally first: from then on
rem the guest never needs another file transfer.
if not exist C:\norbourg mkdir C:\norbourg
xcopy "%~dp0*.*" C:\norbourg\ /E /I /Y >nul 2>&1
powershell -NoProfile -ExecutionPolicy Bypass -File "C:\norbourg\bootstrap.ps1" >> C:\norbourg\bootstrap.log 2>&1

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

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Before

Width:  |  Height:  |  Size: 54 B

After

Width:  |  Height:  |  Size: 54 B

Before

Width:  |  Height:  |  Size: 458 B

After

Width:  |  Height:  |  Size: 458 B

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Before

Width:  |  Height:  |  Size: 51 B

After

Width:  |  Height:  |  Size: 51 B

Before

Width:  |  Height:  |  Size: 54 B

After

Width:  |  Height:  |  Size: 54 B

Before

Width:  |  Height:  |  Size: 138 B

After

Width:  |  Height:  |  Size: 138 B

Before

Width:  |  Height:  |  Size: 51 B

After

Width:  |  Height:  |  Size: 51 B

Some files were not shown because too many files have changed in this diff Show More