Files
pentest.intro/content/windows/roles/fs01.ps1
T
quoije 890dd58700 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.
2026-10-22 19:23:16 -04:00

72 lines
2.4 KiB
PowerShell

# Norbourg lab — FS01: file server and the archived site.
# The web root's "public" folder is both an IIS directory and the SMB share,
# so the web and SMB discovery paths lead to the same file.
. "$PSScriptRoot\..\lib\common.ps1"
$self = $PSCommandPath
Write-LabLog 'fs01: starting'
try {
# Re-running provision must not try to join a machine that already joined.
if ((Get-CimInstance Win32_ComputerSystem).Domain -eq '@@DOMAIN@@') {
Write-LabLog 'fs01: already joined'
Complete-Stage $self 'ok'
return
}
$features = @(
'Web-Server', 'Web-Common-Http', 'Web-Default-Doc',
'Web-Static-Content', 'Web-Dir-Browsing', 'Web-Http-Logging'
)
foreach ($f in $features) {
if (-not (Get-WindowsFeature -Name $f).Installed) {
Write-LabLog "fs01: installing $f"
$null = Install-WindowsFeature -Name $f -IncludeManagementTools
}
}
$root = 'C:\inetpub\wwwroot'
$public = Join-Path $root 'public'
New-Item -ItemType Directory -Force -Path $public | Out-Null
# Directory browsing only where the lab wants it: the leftover upload dir.
$webconfig = @'
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="true" />
</system.webServer>
</configuration>
'@
Set-Content -Path (Join-Path $public 'web.config') -Value $webconfig -Encoding UTF8
if (-not (Get-SmbShare -Name 'Public' -ErrorAction SilentlyContinue)) {
New-SmbShare -Name 'Public' -Path $public -ReadAccess 'Everyone' | Out-Null
Write-LabLog 'fs01: share Public created'
}
# Placeholder so a fresh box is not an empty directory listing.
$placeholder = Join-Path $public 'lisez-moi.txt'
if (-not (Test-Path $placeholder)) {
Set-Content -Path $placeholder -Encoding ascii -Value @'
Depot public du site norbourg.lab
Les formulaires du site deposent leurs pieces jointes ici.
Ne pas supprimer.
'@
}
$cred = New-Object System.Management.Automation.PSCredential(
'@@DOMAIN@@\Administrator',
(ConvertTo-SecureString '@@ADMIN_PASSWORD@@' -AsPlainText -Force))
Write-LabLog 'fs01: joining the domain'
Add-Computer -DomainName '@@DOMAIN@@' -Credential $cred `
-OUPath 'OU=Ordinateurs,OU=Norbourg,@@BASE_DN@@' -Force
Complete-Stage $self 'ok reboot'
Restart-Computer -Force
} catch {
Fail-Stage $self $_.Exception.Message
}