Common attacks and weaknesses
- Remote command execution with any valid admin credentials.
- Lateral movement (Evil-WinRM).
- Brute force when exposed.
Windows Remote Management over HTTP, used by PowerShell Remoting. Messages are encrypted by Kerberos or NTLM, but the transport is HTTP.
The client opens a session to port 5985: each command typed is sent to the server, which runs it and returns the output. Encryption is optional: traffic is only protected if TLS is enabled on the server and the client.
| Service | Port | Transport | Description | Reference | Updated |
|---|---|---|---|---|---|
| wsman | 5985 | TCP, UDP | WBEM WS-Management HTTP | - | 2006-11 |
// source: IANA service name and port number registry
Linux
sudo ss -ltnup 'sport = :5985' # process listening on 5985
sudo lsof -nP -i :5985macOS
sudo lsof -nP -i :5985
Windows (PowerShell)
Get-NetTCPConnection -LocalPort 5985 -State Listen | Select LocalAddress, OwningProcess Get-NetUDPEndpoint -LocalPort 5985 netstat -ano | findstr :5985
From another machine
nmap -p 5985 -sV <host> sudo nmap -sU -p 5985 <host> nc -zv <host> 5985
Block it in the firewall
sudo ufw deny 5985/tcp # Linux (ufw) New-NetFirewallRule -DisplayName "Block 5985" -Direction Inbound -LocalPort 5985 -Protocol TCP -Action Block # Windows
Windows Remote Management over HTTP, used by PowerShell Remoting. Messages are encrypted by Kerberos or NTLM, but the transport is HTTP.
Port 5985 is registered for TCP and UDP. In practice the service mostly uses TCP.
It is rated 8/10 (high) when exposed to the Internet. Remote command execution with any valid admin credentials. Restrict to admin subnets with host firewalls.
On Linux run "ss -ltnup 'sport = :5985'", on macOS "lsof -nP -i :5985", and on Windows "netstat -ano | findstr :5985" to see the local process. From another machine, "nmap -p 5985 <host>" shows whether it is reachable.