Split into qemu and proxmox platforms over a shared content tree

platforms/qemu and platforms/proxmox each have their own lab.sh and
lab.conf; content/ holds everything shared (roles, seed, site, helpers).
The dispatcher, preflight and command implementations are common and take
platform differences from the backend.

Proxmox backend: qm create with q35/SATA/e1000, ISOs and seed ISOs in an
ISO storage, provisioning over qm guest exec (no Python packages needed on
the host), template + clone for reset, and peers/ to emit WireGuard configs.
The role scripts now ride on the seed ISO, so provisioning transfers nothing.

build-bundle.sh produces a self-contained tarball per platform, for hosts
that cannot reach the git server.

Both configs are generic: no absolute path from this machine remains.
This commit is contained in:
2026-10-22 19:23:16 -04:00
parent 538fb9a117
commit 890dd58700
349 changed files with 1142 additions and 2236 deletions
+152
View File
@@ -0,0 +1,152 @@
# Norbourg lab — DC01 stage 2: directory content, misconfigurations, flags.
# Runs once at startup as SYSTEM, right after the promotion reboot.
. "$PSScriptRoot\..\lib\common.ps1"
$self = $PSCommandPath
Write-LabLog 'dc01: post stage starting'
try {
Wait-ForDomain 900
Import-Module ActiveDirectory
Write-LabLog 'dc01: directory services reachable'
$dom = Get-ADDomain
$base = $dom.DistinguishedName
# ------------------------------------------------------------ structure
$ous = @('Norbourg', 'Utilisateurs', 'TI', 'Groupes', 'Ordinateurs')
foreach ($ou in $ous) {
$path = "OU=$ou,$base"
if ($ou -eq 'Norbourg') { $path = "OU=Norbourg,$base" }
if (-not (Get-ADOrganizationalUnit -Filter "Name -eq '$ou'" -SearchBase $base -ErrorAction SilentlyContinue)) {
New-ADOrganizationalUnit -Name $ou -Path $(if ($ou -eq 'Norbourg') { $base } else { "OU=Norbourg,$base" }) -ProtectedFromAccidentalDeletion $false
Write-LabLog "dc01: OU $ou created"
}
}
# ------------------------------------------------------------ users
$users = @(
@{ Sam='m.legault'; Given='Marie'; Surname='Legault'; Pwd='Maple2024!'; OU='TI'; Title='Directrice des TI' }
@{ Sam='s.bergeron'; Given='Sophie'; Surname='Bergeron'; Pwd='Nuage2024!'; OU='TI'; Title='Technicienne, soutien aux usagers' }
@{ Sam='helpdesk1'; Given='Sylvie'; Surname='Tremblay'; Pwd='Welcome2024!'; OU='TI'; Title='Compte partage du helpdesk' }
@{ Sam='svc_backup'; Given='Service'; Surname='Sauvegarde'; Pwd='Backup2023!'; OU='TI'; Title='Compte de service, sauvegarde' }
@{ Sam='t.smith'; Given='Thomas'; Surname='Smith'; Pwd='Str0ngAdmin!2026'; OU='TI'; Title='Administrateur de domaine' }
@{ Sam='j.contractor'; Given='Jacques'; Surname='Contractor'; Pwd='Winter2024!'; OU='Utilisateurs'; Title='Consultant, migration' }
@{ Sam='a.gagnon'; Given='Annie'; Surname='Gagnon'; Pwd='Riviere2023!'; OU='Utilisateurs'; Title='Comptabilite' }
@{ Sam='p.roy'; Given='Pierre'; Surname='Roy'; Pwd='Foret2022!'; OU='Utilisateurs'; Title='Analyste, operations' }
)
foreach ($u in $users) {
if (Get-ADUser -Filter "SamAccountName -eq '$($u.Sam)'" -ErrorAction SilentlyContinue) {
Write-LabLog "dc01: user $($u.Sam) exists"
continue
}
$ou = if ($u.OU -eq 'TI') { "OU=TI,OU=Norbourg,$base" } else { "OU=Utilisateurs,OU=Norbourg,$base" }
New-ADUser -SamAccountName $u.Sam `
-Name "$($u.Given) $($u.Surname)" `
-GivenName $u.Given -Surname $u.Surname `
-DisplayName "$($u.Given) $($u.Surname)" `
-Title $u.Title `
-Path $ou `
-AccountPassword (ConvertTo-SecureString $u.Pwd -AsPlainText -Force) `
-Enabled $true -PasswordNeverExpires $true -ChangePasswordAtLogon $false
Write-LabLog "dc01: user $($u.Sam) created"
}
# ------------------------------------------------------------ groups
$groups = @{
'TI-Support' = @('s.bergeron', 'helpdesk1')
'WS Admins' = @('svc_backup')
'Serveurs-Admins' = @('m.legault')
}
foreach ($name in $groups.Keys) {
if (-not (Get-ADGroup -Filter "Name -eq '$name'" -ErrorAction SilentlyContinue)) {
New-ADGroup -Name $name -GroupScope Global -GroupCategory Security -Path "OU=Groupes,OU=Norbourg,$base"
Write-LabLog "dc01: group $name created"
}
foreach ($member in $groups[$name]) {
try { Add-ADGroupMember -Identity $name -Members $member -ErrorAction Stop }
catch { Write-LabLog "dc01: $member already in $name" }
}
}
try { Add-ADGroupMember -Identity 'Domain Admins' -Members 't.smith' -ErrorAction Stop }
catch { Write-LabLog 'dc01: t.smith already Domain Admin' }
# ------------------------------------------------------------ misconfigs
# Kerberoastable: an SPN on a normal user account.
Set-ADUser -Identity 'svc_backup' -ServicePrincipalNames @{ Add = 'MSSQLSvc/fs01.norbourg.lab:1433' }
Write-LabLog 'dc01: SPN set on svc_backup'
# AS-REP roastable: pre-authentication disabled.
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.
# 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'
}
# ------------------------------------------------------------ dns
try {
Add-DnsServerResourceRecordA -Name 'www' -ZoneName '@@DOMAIN@@' -IPv4Address '10.10.10.20' -ErrorAction Stop
Write-LabLog 'dc01: www A record created'
} catch {
Write-LabLog 'dc01: www A record already present'
}
# ------------------------------------------------------------ flags
$flagDir = 'C:\flag'
New-Item -ItemType Directory -Force -Path $flagDir | Out-Null
$rootPath = Join-Path $flagDir 'root.txt'
if (-not (Test-Path $rootPath)) {
Set-Content -Path $rootPath -Value 'NORBOURG{do_m41n_4dm1n_0n_dc01}' -Encoding ascii
}
# Administrators only: SYSTEM + Domain Admins inherit through the default ACL.
$acl = Get-Acl $flagDir
$acl.SetAccessRuleProtection($true, $false)
foreach ($id in @('BUILTIN\Administrators', 'NT AUTHORITY\SYSTEM')) {
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule(
$id, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')
$acl.AddAccessRule($rule)
}
Set-Acl -Path $flagDir -AclObject $acl
Write-LabLog 'dc01: root.txt in place'
# The GenericAll path ends in a password reset; the default one-day
# minimum password age blocks it, and it is a plausible weak setting.
Set-ADDefaultDomainPasswordPolicy -Identity '@@DOMAIN@@' -MinPasswordAge '00:00:00'
Write-LabLog 'dc01: minimum password age set to zero'
# ------------------------------------------------------------ auditing
# Legacy policy off, advanced subcategories on: this is what the blue-team
# debrief reads back from the event log.
$lsa = 'HKLM:\SYSTEM\CurrentControlSet\Control\Lsa'
Set-ItemProperty -Path $lsa -Name SCENoApplyLegacyAuditPolicy -Value 1 -Type DWord
$subcategories = @(
'Kerberos Authentication Service',
'Kerberos Service Ticket Operations',
'Logon',
'User Account Management',
'Directory Service Access',
'Directory Service Changes',
'Computer Account Management'
)
foreach ($sub in $subcategories) {
$null = auditpol.exe /set /subcategory:"$sub" /success:enable /failure:enable
}
Write-LabLog 'dc01: advanced audit policy enabled'
Complete-Stage $self 'ok'
} catch {
Fail-Stage $self $_.Exception.Message
}