snapshot freezes each golden disk into images/base/ and boots a thin overlay; reset recreates the overlay in about a second. Shutdown now asks the guest over WinRM because ACPI powerdown is ignored by Server 2022. dc01-post: grant GenericAll with dsacls (the .NET ACL API reported success but never persisted the ACE) and set MinPasswordAge to zero, without which the ACL reset fails. Attack path validated end to end against the live lab: web -> SMB creds -> AS-REP -> Kerberoast -> WinRM -> GenericAll reset -> DCSync.
159 lines
4.3 KiB
Bash
Executable File
159 lines
4.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# lab.sh — entry point for the Norbourg pentest lab.
|
|
# Backend-agnostic commands live in lib/, backend specifics in backends/.
|
|
set -euo pipefail
|
|
|
|
LAB_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd -P)
|
|
export LAB_DIR
|
|
|
|
# shellcheck source=lib/common.sh
|
|
source "$LAB_DIR/lib/common.sh"
|
|
# shellcheck source=lib/check.sh
|
|
source "$LAB_DIR/lib/check.sh"
|
|
# shellcheck source=lib/cmd_init.sh
|
|
source "$LAB_DIR/lib/cmd_init.sh"
|
|
# shellcheck source=lib/cmd_web.sh
|
|
source "$LAB_DIR/lib/cmd_web.sh"
|
|
# shellcheck source=lib/cmd_isos.sh
|
|
source "$LAB_DIR/lib/cmd_isos.sh"
|
|
# shellcheck source=lib/cmd_seeds.sh
|
|
source "$LAB_DIR/lib/cmd_seeds.sh"
|
|
# shellcheck source=lib/cmd_build.sh
|
|
source "$LAB_DIR/lib/cmd_build.sh"
|
|
# shellcheck source=lib/cmd_provision.sh
|
|
source "$LAB_DIR/lib/cmd_provision.sh"
|
|
# shellcheck source=lib/cmd_snapshot.sh
|
|
source "$LAB_DIR/lib/cmd_snapshot.sh"
|
|
|
|
usage() {
|
|
cat <<EOF
|
|
Norbourg lab ${LAB_SH_VERSION}
|
|
|
|
Usage: ./lab.sh [options] <command>
|
|
|
|
Options:
|
|
--backend qemu|proxmox override lab.conf
|
|
--strict treat check warnings as failures
|
|
-v, --verbose extra detail
|
|
-h, --help this text
|
|
|
|
Commands:
|
|
check preflight: host, KVM, storage, network, config
|
|
init create the storage layout
|
|
isos download the Windows media into LAB_ISO_CACHE
|
|
seeds render unattend files and pack the seed ISOs
|
|
build create VMs, run unattended installs (phase 3)
|
|
provision run role scripts over WinRM (--role NAME for one)
|
|
snapshot freeze a clean baseline (stops the VMs)
|
|
up, down start / stop the VMs (phase 3)
|
|
reset revert to the baseline and start
|
|
status VM table: state, pid, VNC display
|
|
vnc open a console on a VM
|
|
web sync the archived site to FS01 (phase 7)
|
|
doctor participant connectivity checklist (phase 8)
|
|
peers WireGuard peer configs (proxmox only) (phase 11)
|
|
export-kali build the participant Kali image (phase 9)
|
|
answers instructor walkthrough (phase 9)
|
|
destroy remove VMs and generated artifacts (phase 8)
|
|
EOF
|
|
}
|
|
|
|
planned() {
|
|
warn "'$1' is not implemented yet — planned for $2"
|
|
return 3
|
|
}
|
|
|
|
# ------------------------------------------------------------------ arguments
|
|
BACKEND_OVERRIDE=""
|
|
cmd=""
|
|
|
|
while (( $# > 0 )); do
|
|
case $1 in
|
|
--backend)
|
|
[[ $# -ge 2 ]] || die "--backend needs a value (qemu|proxmox)"
|
|
BACKEND_OVERRIDE=$2
|
|
shift 2
|
|
;;
|
|
--backend=*)
|
|
BACKEND_OVERRIDE=${1#*=}
|
|
shift
|
|
;;
|
|
--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.
|
|
if [[ -z $cmd ]]; then
|
|
die "unknown option: $1 (try --help)"
|
|
fi
|
|
break
|
|
;;
|
|
*)
|
|
if [[ -z $cmd ]]; then
|
|
cmd=$1
|
|
shift
|
|
else
|
|
die "unexpected argument: $1 (try --help)"
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [[ -z $cmd ]]; then
|
|
usage
|
|
exit 2
|
|
fi
|
|
|
|
load_config
|
|
[[ -n $BACKEND_OVERRIDE ]] && BACKEND=$BACKEND_OVERRIDE
|
|
|
|
case $BACKEND in
|
|
qemu|proxmox)
|
|
# shellcheck source=backends/qemu.sh
|
|
source "$LAB_DIR/backends/${BACKEND}.sh"
|
|
;;
|
|
*)
|
|
die "unknown backend: ${BACKEND} (expected qemu or proxmox)"
|
|
;;
|
|
esac
|
|
|
|
# ------------------------------------------------------------------ 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) planned doctor "phase 8" ;;
|
|
peers) planned peers "phase 11" ;;
|
|
export-kali) planned export-kali "phase 9" ;;
|
|
answers) planned answers "phase 9" ;;
|
|
destroy) planned destroy "phase 8" ;;
|
|
*) die "unknown command: ${cmd} (try --help)" ;;
|
|
esac
|