Files
pentest.intro/session1/content/lib/dispatch.sh
T
quoije ef6fe18333 proxmox: one turnkey Kali VM per participant
Deploy N attacker VMs alongside the domain lab and hand each colleague a
console URL, with nothing to install or configure on their side.

- import the Kali image once, keep it as a template, clone per seat
- deterministic MAC + DHCP reservation on DC01, so addresses are stable
- configure through the QEMU guest agent: hostname, wordlist from the
  tool ISO, sshd, then verify network and DNS
- add the `users` command: a PVEVMUser account scoped to one VM plus the
  noVNC URL and generated password
- check: 7z/pveum presence, address range, RAM budget for the clones
- destroy cleans up the clones and the template

The documented path no longer depends on bloodyAD: the password reset uses
impacket-changepasswd (already installed) and ACL inspection uses nxc's
daclread module, both verified against the live lab.
2026-10-24 14:57:38 -04:00

112 lines
3.4 KiB
Bash

# 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
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 attacker VM(s)
answers print the instructor walkthrough
destroy remove the VMs and generated artifacts
EOF
case $PLATFORM in
proxmox)
printf ' users create a Proxmox account + console URL per participant\n'
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 "$@" ;;
save) cmd_save "$@" ;;
reset) cmd_reset "$@" ;;
doctor) cmd_doctor "$@" ;;
kali) cmd_kali "$@" ;;
users) cmd_users "$@" ;;
answers) cmd_answers "$@" ;;
destroy) cmd_destroy "$@" ;;
peers) cmd_peers "$@" ;;
*) die "unknown command: ${cmd} (try --help)" ;;
esac