WinRM
Pentesting WinRM - TCP Ports 5985,5986
Theory
Windows Remote Management (WinRM) is a Microsoft protocol that allows remote management of Windows machines over HTTP(S) using SOAP. On the backend it's utilising WMI, so you can think of it as an HTTP based API for WMI. If WinRM is enabled on the machine, it's trivial to remotely administer the machine from PowerShell. In fact, you can just drop in to a remote PowerShell session on the machine (as if you were using SSH!) The easiest way to detect whether WinRM is available is by seeing if the port is opened. WinRM will listen on one of two ports: 5985/tcp (HTTP) or 5986/tcp (HTTPS)
Practice
Targeting Accounts
Be careful, brute-forcing winrm could block users.
Enable WinRM
Most Windows Server installations will have WinRM enabled by default, making it an attractive attack vector. However, for instances where this is not the case, we can enable it using powershell
If we have access to an elevated PowerShell prompt on the victim, we cam enable it and add any "attackers" as trusted hosts. We can run the following two commands
We can also activate WinRM remotely using wmic
Execute Remote Commands
Resources
Last updated