Run role scripts as a scheduled task; add workshop docs

A Start-Process child dies with the WinRM shell, so the promotion never
completed. Role scripts now run under the Task Scheduler as SYSTEM, which
survives the disconnect and the reboot. Uploads retry on transient auth
errors while a guest is busy installing features.

Docs: participant guide, instructor runbook, blue-team debrief, and an
instructor wordlist sized for a two-minute crack.
This commit is contained in:
2026-10-21 19:45:38 -04:00
parent 279f4cc547
commit bb8a6a6eb0
4 changed files with 209 additions and 16 deletions
+17 -4
View File
@@ -9,6 +9,18 @@ _winrm() {
"$@" --user "$LAB_USER" --password "$LAB_ADMIN_PASSWORD"
}
# A guest that is installing features or restarting WinRM answers intermittently.
_winrm_retry() {
local n=1
while (( n <= 5 )); do
if _winrm "$@"; then return 0; fi
warn "winrm attempt ${n}/5 failed, retrying"
sleep 15
n=$(( n + 1 ))
done
return 1
}
_wait_winrm() {
local host=$1 timeout=${2:-1800}
local deadline=$(( SECONDS + timeout ))
@@ -40,20 +52,21 @@ _provision_one() {
rm -rf "$work"; mkdir -p "$work"
_render_role "$LAB_DIR/windows/roles/$role.ps1" "$work/$role.ps1"
[[ -s $work/$role.ps1 ]] || die "$name: role script missing or empty: windows/roles/$role.ps1"
_winrm "$ip" put "$LAB_DIR/windows/lib/common.ps1" 'C:\norbourg\lib\common.ps1' \
_winrm_retry "$ip" put "$LAB_DIR/windows/lib/common.ps1" 'C:\norbourg\lib\common.ps1' \
|| die "$name: could not upload common.ps1"
_winrm "$ip" put "$work/$role.ps1" "C:\\norbourg\\roles\\$role.ps1" \
_winrm_retry "$ip" put "$work/$role.ps1" "C:\\norbourg\\roles\\$role.ps1" \
|| die "$name: could not upload $role.ps1"
local post="$LAB_DIR/windows/roles/$role-post.ps1"
if [[ -f $post ]]; then
_render_role "$post" "$work/$role-post.ps1"
_winrm "$ip" put "$work/$role-post.ps1" "C:\\norbourg\\roles\\$role-post.ps1" \
_winrm_retry "$ip" put "$work/$role-post.ps1" "C:\\norbourg\\roles\\$role-post.ps1" \
|| die "$name: could not upload $role-post.ps1"
fi
_winrm "$ip" start "C:\\norbourg\\roles\\$role.ps1" "C:\\norbourg\\roles\\$role.log" \
_winrm_retry "$ip" start "C:\\norbourg\\roles\\$role.ps1" "C:\\norbourg\\roles\\$role.log" \
|| die "$name: could not start $role.ps1"
info " running, waiting for the stage marker"