dc01: make the delegated ACL the only way out, and stabilise the state
Three shortcuts and one race made the lab either easier than documented or non-deterministic: - Serveurs-Admins was nested in BUILTIN\Administrators on the DC, so m.legault was a de-facto domain-controller admin (C$, NTDS.dit) and the whole ACL lesson could be skipped. It also made SDProp treat her as protected: an hour after provisioning, the intended GenericAll ACE was wiped. Removed the nesting; adminCount is explicitly reset. - the t.smith decoy ACE gave a working path to Domain Admin until SDProp ran (up to an hour after a fresh build). The role now grants it and revokes it immediately, so the state is deterministic. - the replication-rights grant stacked duplicate ACEs on every re-run; it now removes its own ACEs first. - up/reset/save returned as soon as WinRM answered, while the directory was still starting; doctor right after could report a missing ACE and missing replication rights on a healthy lab. They now wait for Get-ADDomain on dc01. doctor: a decoy ACE that is still present is now a failure, not a success. The deck's wording matches the new behaviour.
This commit is contained in:
@@ -92,17 +92,17 @@ try {
|
||||
Set-ADAccountControl -Identity 'j.contractor' -DoesNotRequirePreAuth $true
|
||||
Write-LabLog 'dc01: pre-auth disabled on j.contractor'
|
||||
|
||||
# ACL abuse: svc_backup has GenericAll on a Domain Admin.
|
||||
# ACL abuse: svc_backup has GenericAll on a Domain Admin. SDProp resets a
|
||||
# protected object's ACL within the hour, so the lab grants the ACE and
|
||||
# revokes it immediately: a participant who finds it in the first hour
|
||||
# could reset a Domain Admin's password and skip the intended path.
|
||||
# dsacls is used instead of the .NET ACL API, which returns success but
|
||||
# does not persist the ACE through the AD provider.
|
||||
$targetDn = (Get-ADUser 't.smith').DistinguishedName
|
||||
$aclCheck = dsacls.exe $targetDn | Select-String 'svc_backup'
|
||||
if (-not $aclCheck) {
|
||||
$null = dsacls.exe $targetDn /G '@@NETBIOS@@\svc_backup:GA'
|
||||
Write-LabLog 'dc01: GenericAll granted to svc_backup over t.smith'
|
||||
} else {
|
||||
Write-LabLog 'dc01: svc_backup already has an ACE on t.smith'
|
||||
}
|
||||
$null = dsacls.exe $targetDn /G '@@NETBIOS@@\svc_backup:GA'
|
||||
Write-LabLog 'dc01: GenericAll granted to svc_backup over t.smith (decoy)'
|
||||
$null = dsacls.exe $targetDn /R '@@NETBIOS@@\svc_backup'
|
||||
Write-LabLog 'dc01: decoy ACE on t.smith revoked (SDProp would do it within the hour)'
|
||||
|
||||
# The backup product needs directory replication rights for AD-aware
|
||||
# backups. That is what makes m.legault reach the DC without being in a
|
||||
@@ -110,8 +110,22 @@ try {
|
||||
$svcGroup = Get-ADGroup 'Sauvegarde-AD'
|
||||
$domainAcl = [ADSI]("LDAP://$base")
|
||||
$sd = $domainAcl.ObjectSecurity
|
||||
foreach ($rightGuid in @('1131f6aa-9c07-11d1-f79f-00c04fc2dcd2',
|
||||
'1131f6ad-9c07-11d1-f79f-00c04fc2dcd2')) {
|
||||
$rightGuids = @('1131f6aa-9c07-11d1-f79f-00c04fc2dcd2',
|
||||
'1131f6ad-9c07-11d1-f79f-00c04fc2dcd2')
|
||||
$sidText = $svcGroup.SID.Value
|
||||
$nameText = '@@NETBIOS@@\Sauvegarde-AD'
|
||||
|
||||
# Idempotent: a re-run must not stack duplicate ACEs on the domain.
|
||||
foreach ($ace in @($sd.Access)) {
|
||||
if ($ace.IsInherited) { continue }
|
||||
$trustee = $ace.IdentityReference.Value
|
||||
if (($trustee -eq $sidText -or $trustee -eq $nameText) -and
|
||||
($rightGuids -contains $ace.ObjectType.Guid.ToString())) {
|
||||
[void]$sd.RemoveAccessRule($ace)
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($rightGuid in $rightGuids) {
|
||||
$rule = New-Object System.DirectoryServices.ActiveDirectoryAccessRule(
|
||||
$svcGroup.SID,
|
||||
[System.DirectoryServices.ActiveDirectoryRights]::ExtendedRight,
|
||||
@@ -139,13 +153,10 @@ try {
|
||||
Write-LabLog 'dc01: GenericAll granted to svc_backup over m.legault'
|
||||
}
|
||||
|
||||
# m.legault reaches DC admin through the server group.
|
||||
try {
|
||||
Add-ADGroupMember -Identity 'S-1-5-32-544' -Members 'Serveurs-Admins' -ErrorAction Stop
|
||||
Write-LabLog 'dc01: Serveurs-Admins added to BUILTIN\Administrators'
|
||||
} catch {
|
||||
Write-LabLog 'dc01: Serveurs-Admins already in BUILTIN\Administrators'
|
||||
}
|
||||
# Deliberately NOT added to BUILTIN\Administrators: a local admin on the
|
||||
# DC can read C$ and NTDS.dit, which is a shortcut around the whole ACL
|
||||
# path. The lab's lesson is the delegated ACE plus the replication right,
|
||||
# not "the account happens to be a domain-controller admin".
|
||||
|
||||
# ------------------------------------------------------------ dns
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user