From b13ec8da953da4ff73f877726141cfbfd852a020 Mon Sep 17 00:00:00 2001 From: Mathieu Moran Date: Fri, 23 Oct 2026 07:14:19 -0400 Subject: [PATCH] Persist the Kali setup in its base image New 'kali snapshot' subcommand commits the working overlay into the base image, the same way the Windows guests are frozen. After it, reset returns to a Kali that already has: the wordlist under /opt/norbourg, bloodyAD, sshd enabled at boot, and the dual resolver (DC first, slirp second). Verified by booting from the committed base with no manual step: sshd answers, 1716-line wordlist present, bloodyad on PATH, lab and public names both resolving. Docs: README and instructor checklist describe the new step. --- README.md | 6 ++++-- content/lib/cmd_kali.sh | 24 +++++++++++++++++++++++- docs/instructeur.md | 3 +++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ec077fb..e0f2254 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,8 @@ Impacket, `evil-winrm`, `hashcat` et `bloodhound-python` ; `bloodyAD` s'ajoute a ```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 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 ``` @@ -100,7 +101,8 @@ Identifiants par défaut : `kali` / `kali`. La VM a deux cartes : le pont du lab 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 : +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 diff --git a/content/lib/cmd_kali.sh b/content/lib/cmd_kali.sh index 384f528..4cf1381 100644 --- a/content/lib/cmd_kali.sh +++ b/content/lib/cmd_kali.sh @@ -62,8 +62,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 } @@ -177,6 +178,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" diff --git a/docs/instructeur.md b/docs/instructeur.md index 44c2879..e35d690 100644 --- a/docs/instructeur.md +++ b/docs/instructeur.md @@ -62,6 +62,9 @@ site et le partage `Public`, `ws01` est joint au domaine avec `user.txt` en plac sudo mount /dev/sr0 /mnt && sudo cp /mnt/norbourg.txt /opt/norbourg/wordlists/ ``` + Puis figez l'état : `cd platforms/qemu && ./lab.sh kali snapshot`. Sans cela, `kali reset` + ramène l'image d'origine et la liste de mots disparaît. + 4. **Outils dans Kali** : l'image officielle contient déjà `nxc`, Impacket, `evil-winrm`, `hashcat` et `bloodhound-python`. L'interface BloodHound n'y est pas et n'est pas nécessaire. S'il manque `bloodyAD` : `sudo apt install bloodyad` (nécessite Internet, donc avant de