Files
pentest.intro/lab.sh
T
quoije 279f4cc547 Phase 5: AD role scripts, WinRM provisioning and lab wordlist
dc01 promotes the forest then runs a startup-scheduled post stage for OUs,
users, groups, the SPN on svc_backup, pre-auth disabled on j.contractor,
GenericAll over t.smith, the www A record, flags and advanced audit policy.
fs01 installs IIS, shares the web root's public/ as \\FS01\Public and joins.
ws01 joins, then adds WS Admins to local Administrators.

provision uploads over WinRM, starts scripts detached, waits on a .done
marker and survives the promotion reboot.
2026-10-21 19:29:51 -04:00

157 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"
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 (phase 8)
up, down start / stop the VMs (phase 3)
reset revert to baseline (phase 8)
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) planned snapshot "phase 8" ;;
reset) planned reset "phase 8" ;;
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