From 723586029f494156f2d3a326cc4205100bd5d188 Mon Sep 17 00:00:00 2001 From: Mathieu Moran Date: Sat, 24 Oct 2026 01:36:33 -0400 Subject: [PATCH] Fix the ACL being reverted by SDProp, and make doctor check the puzzle t.smith is a Domain Admin, therefore a protected object: SDProp rewrites his security descriptor every hour from AdminSDHolder and deletes any ACE not present there. The GenericAll that the lab builds was silently removed by that cycle, so 'bloodyad set password' started failing with the misleading 'oldpass not valid' error. Clearing adminCount on the target takes it out of SDProp's scope while it stays a Domain Admin. Applied in dc01-post.ps1 (guarded) and baked into the baseline. doctor now verifies the invariants that services do not reveal: the ACE, adminCount, SPN, disabled pre-auth, minimum password age, root.txt, the easter-egg TXT and the DHCP scope. This is exactly the drift that was invisible before. --- content/lib/cmd_doctor.sh | 40 +++++++++++++++++++++++++++++ content/windows/roles/dc01-post.ps1 | 11 ++++++++ 2 files changed, 51 insertions(+) diff --git a/content/lib/cmd_doctor.sh b/content/lib/cmd_doctor.sh index d6a2c2d..07fe19c 100644 --- a/content/lib/cmd_doctor.sh +++ b/content/lib/cmd_doctor.sh @@ -62,6 +62,9 @@ cmd_doctor() { _d_warn "dig not installed, DNS checks skipped" fi + step "lab state" + _lab_state + step "web" local code code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 "http://10.10.10.20/" 2>/dev/null || true) @@ -96,3 +99,40 @@ cmd_doctor() { fi ok "laboratory healthy ยท ${DOCTOR_WARNS} warning(s)" } + + +# The puzzle has invariants that services do not reveal: a delegated right, +# an SPN, a disabled pre-authentication, a password policy. SDProp quietly +# reverts ACEs on protected objects, so this is worth checking every time. +_lab_state() { + local out key value + out=$(backend_ps dc01 ' +Import-Module ActiveDirectory,DnsServer +$dn = (Get-ADUser t.smith).DistinguishedName +$acl = Get-Acl ("AD:\" + $dn) +"ace=" + @($acl.Access | Where-Object { $_.IdentityReference.Value -like "*svc_backup*" }).Count +"admincount=" + (Get-ADUser t.smith -Properties adminCount).adminCount +"spn=" + @((Get-ADUser svc_backup -Properties ServicePrincipalNames).ServicePrincipalNames).Count +"preauth=" + (Get-ADUser j.contractor -Properties DoesNotRequirePreAuth).DoesNotRequirePreAuth +"minage=" + (Get-ADDefaultDomainPasswordPolicy).MinPasswordAge.TotalHours +"root=" + (Test-Path C:\flag\root.txt) +"txt=" + ((Get-DnsServerResourceRecord -ZoneName norbourg.lab -Name yourlove -EA SilentlyContinue) -ne $null) +"dhcp=" + ((Get-DhcpServerv4Scope -EA SilentlyContinue) -ne $null) +' 2>/dev/null) || { _d_warn "cannot query DC01 for lab state"; return; } + + while IFS='=' read -r key value; do + value=${value//$'\r'/} + case $key in + ace) if [[ $value -ge 1 ]]; then _d_ok "delegated right: svc_backup has an ACE on t.smith" + else _d_fail "delegated right missing (ACE on t.smith)"; fi ;; + admincount) if [[ $value == 0 ]]; then _d_ok "t.smith outside SDProp (adminCount=0)" + else _d_warn "adminCount=$value: SDProp will delete the ACE within the hour"; fi ;; + spn) [[ $value -ge 1 ]] && _d_ok "service account: SPN present" || _d_fail "svc_backup has no SPN" ;; + preauth) [[ $value == True ]] && _d_ok "pre-auth disabled on j.contractor" || _d_fail "j.contractor still requires pre-auth" ;; + minage) [[ $value == 0 ]] && _d_ok "minimum password age: 0" || _d_fail "minimum password age is $value h" ;; + root) [[ $value == True ]] && _d_ok "root.txt on DC01" || _d_fail "root.txt missing" ;; + txt) [[ $value == True ]] && _d_ok "easter egg TXT record" || _d_warn "yourlove TXT record missing" ;; + dhcp) [[ $value == True ]] && _d_ok "DHCP scope present" || _d_fail "DHCP scope missing" ;; + esac + done <<< "$out" +} diff --git a/content/windows/roles/dc01-post.ps1 b/content/windows/roles/dc01-post.ps1 index e125aa6..19db2ae 100644 --- a/content/windows/roles/dc01-post.ps1 +++ b/content/windows/roles/dc01-post.ps1 @@ -95,6 +95,17 @@ try { Write-LabLog 'dc01: svc_backup already has an ACE on t.smith' } + # t.smith is a Domain Admin, therefore a "protected" object: SDProp resets + # his security descriptor every hour and deletes any ACE not present in + # AdminSDHolder. Clearing adminCount takes him out of SDProp's scope while + # leaving his Domain Admins membership intact. + try { + Set-ADObject -Identity 't.smith' -Replace @{ adminCount = 0 } -ErrorAction Stop + Write-LabLog 'dc01: t.smith excluded from SDProp (adminCount=0)' + } catch { + Write-LabLog "dc01: could not clear adminCount ($($_.Exception.Message))" + } + # ------------------------------------------------------------ dns try { Add-DnsServerResourceRecordA -Name 'www' -ZoneName '@@DOMAIN@@' -IPv4Address '10.10.10.20' -ErrorAction Stop