Parent : [[INDEX-CYBERSECU]]
Fuite de mot de passe admin via sysprep_unattend.xml - Windows unattended installation
Problème
Sur les serveurs Windows déployés automatiquement, le fichier sysprep_unattend.xml contient les paramètres d'installation, y compris parfois le mot de passe administrateur. Ce fichier aurait dû être supprimé après le déploiement. Il ne l'a pas été. Sur le serveur de pré-production YGG, il a été lu via SphinxQL CALL SNIPPETS et a révélé le mot de passe Administrator en clair.
Contexte archive Ygg
- Source :
https://yggleak.top/fr/home/ygg-dossier#phase-6-security-epic-fail - Phase 6 — Security epic fail
- Fichier :
C:/Windows/Panther/Unattend/sysprep_unattend.xml - Accès : Lecture via SphinxQL
CALL SNIPPETSavecload_files=1 - Résultat : Mot de passe Administrator
&)d(5Hj46B7h5^fQF^c(yKYRP - Autres secrets :
DisableAntiSpyware=true
Technique d'exploitation
1. Recherche du fichier sysprep_unattend.xml
CALL SNIPPETS('C:/Windows/Panther/Unattend/sysprep_unattend.xml', 'users', 'password', 1 AS load_files, 50000 AS around, 0 AS limit);
2. Extraction du mot de passe
Résultat :
<AutoLogon>
<Username>Administrator</Username>
<Password>
<Value>&)d(5Hj46B7h5^fQF^c(yKYRP</Value>
<PlainText>true</PlainText>
</Password>
</AutoLogon>
Problèmes :
<PlainText>true</PlainText>: Mot de passe en clair- Fichier non supprimé après déploiement
- Accessible via un service vulnérable (SphinxQL)
3. Accès total au serveur
smbclient //X.X.X.X/C$ \
-U 'Administrator%&)d(5Hj46B7h5^fQF^c(yKYRP' \
--option='client min protocol=SMB2'
# Accès confirmé. Lecture et écriture sur l'intégralité du disque C:
Solution protectif — Sécurisation du déploiement Windows
1. Supprimer sysprep_unattend.xml après déploiement
# post-deployment-cleanup.ps1
# À exécuter immédiatement après le déploiement
# Supprimer les fichiers unattended
Remove-Item -Path "C:\Windows\Panther\Unattend\*" -Force -Recurse
Remove-Item -Path "C:\Windows\Panther\sysprep_unattend.xml" -Force
Remove-Item -Path "C:\Windows\System32\Sysprep\Panther\*" -Force -Recurse
# Vider le dossier Panther
Remove-Item -Path "C:\Windows\Panther\*" -Force -Recurse -ErrorAction SilentlyContinue
# Vider la corbeille de tous les utilisateurs
Get-ChildItem "C:\`$Recycle.Bin" -Force | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
2. Chiffrer le mot de passe dans unattend.xml
<!-- unattend.xml sécurisé -->
<AutoLogon>
<Password>
<Value>/*VOTRE_MOT_DE_PASSE_CHIFFRE*/</Value>
<PlainText>false</PlainText>
</Password>
</AutoLogon>
<!-- Ou utiliser LAPS (Local Administrator Password Solution) -->
3. Utiliser LAPS (Local Administrator Password Solution)
# Installer LAPS
# https://www.microsoft.com/download/details.aspx?id=46899
# Configurer GPO pour LAPS
Set-AdmPwdComputerSelfPermission -OrgUnit "OU=Servers,DC=domain,DC=com"
Reset-AdmPwdPassword -ComputerName "SERVEUR-PREPROD" -WhenEffective (Get-Date)
# Le mot de passe est stocké dans AD et change automatiquement
# Plus de mot de passe dans unattend.xml
4. Détection de fichiers sysprep sensibles
# detect-sysprem-files.ps1
$sysprepPaths = @(
"C:\Windows\Panther\Unattend",
"C:\Windows\Panther",
"C:\Windows\System32\Sysprep\Panther",
"C:\Windows\Setup\Scripts"
)
$suspiciousFiles = @(
"unattend.xml",
"sysprep_unattend.xml",
"autounattend.xml",
"setupcomplete.cmd"
)
foreach ($path in $sysprepPaths) {
if (Test-Path $path) {
foreach ($file in $suspiciousFiles) {
$fullPath = Join-Path $path $file
if (Test-Path $fullPath) {
Write-Warning "[ALERT] Fichier sysprep trouvé: $fullPath"
# Vérifier s'il contient un mot de passe
$content = Get-Content $fullPath -Raw
if ($content -match "<Password>" -or $content -match "PlainText") {
Write-Warning "[CRITICAL] Mot de passe potentiel en clair dans: $fullPath"
}
}
}
}
}
5. Monitoring de l'accès aux fichiers sensibles
# Audit des accès aux fichiers sysprep
$auditRule = New-Object System.Security.AccessControl.FileSystemAuditRule(
"Everyone",
"ReadData,ReadExtendedAttributes",
"Success,Failure"
)
$path = "C:\Windows\Panther"
$acl = Get-Acl $path
$acl.AddAuditRule($auditRule)
Set-Acl $path $acl
# Vérifier les logs de sécurité (Event ID 4663)
Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4663} |
Where-Object { $_.Message -like "*Panther*" -or $_.Message -like "*sysprep*" }
6. Renommer le compte Administrator
# Renommer le compte Administrator (défense en profondeur)
Rename-LocalUser -Name "Administrator" -NewName "SvcAdmin_XJ9"
# Désactiver le compte Administrator
Disable-LocalUser -Name "SvcAdmin_XJ9"
# Créer un compte admin dédié avec mot de passe aléatoire
$securePassword = ConvertTo-SecureString -String (New-RandomPassword -Length 32) -AsPlainText -Force
New-LocalUser -Name "Admin_$(Get-Random)" -Password $securePassword -PasswordNeverExpires $false
Checklist de validation
- Fichiers
unattend.xmlsupprimés après déploiement - Fichiers
sysprep_unattend.xmlsupprimés après déploiement - Mots de passe chiffrés (pas
<PlainText>true</PlainText>) - LAPS installé et configuré pour les mots de passe locaux
- Compte Administrator renommé et désactivé
- Audit d'accès aux répertoires sensibles (Panther, Sysprep)
- Monitoring des Event ID 4663 (accès fichiers)
- Scan régulier des fichiers sysprep résiduels
- Pas de mot de passe dans les logs d'installation
- ISO d'installation personnalisée nettoyée après usage
Anti-pattern associé
KNOW-ANT-013— Leaving sysprep_unattend.xml with plaintext password
Références
- Archive Ygg : Phase 6 — Security epic fail (YGGLeak)
- Microsoft LAPS : https://www.microsoft.com/download/details.aspx?id=46899
- OWASP : Sensitive Data Exposure