Detect Windows Remote Management in Splunk
Adversaries may use Valid Accounts to interact with remote systems using Windows Remote Management (WinRM). WinRM is a Windows service and protocol allowing remote execution of commands, registry modification, and service management. It can be invoked via the winrm command, PowerShell's Invoke-Command/Enter-PSSession, or tools like Evil-WinRM used by Storm-0501. Other users include Cobalt Strike (WinRM for Beacon delivery), Brute Ratel C4, Chimera, and FIN13. WinRM operates over HTTP (5985) and HTTPS (5986) and requires valid credentials plus network access. When disabled by default on client systems, adversaries may first enable it via registry modification or Group Policy.
MITRE ATT&CK
- Tactic
- Lateral Movement
- Technique
- T1021 Remote Services
- Sub-technique
- T1021.006 Windows Remote Management
- Canonical reference
- https://attack.mitre.org/techniques/T1021/006/
SPL Detection Query
index=wineventlog (sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" OR sourcetype="WinEventLog:Microsoft-Windows-WinRM/Operational")
(
(EventCode=1
ParentImage="*\\wsmprovhost.exe"
NOT Image IN ("*\\conhost.exe", "*\\WerFault.exe", "*\\csc.exe")
| eval AlertType="WinRM_RemoteExec_Child"
| table _time, host, User, Image, CommandLine, ParentImage, AlertType)
OR
(EventCode=1
(Image="*\\powershell.exe" OR Image="*\\pwsh.exe")
(CommandLine="*Invoke-Command*" OR CommandLine="*Enter-PSSession*" OR CommandLine="*New-PSSession*" OR CommandLine="*-ComputerName*" OR CommandLine="*wsman://*" OR CommandLine="*winrm*")
| eval AlertType="WinRM_PSRemoting"
| table _time, host, User, Image, CommandLine, ParentImage, AlertType)
OR
(EventCode=1
(Image="*\\winrs.exe" OR CommandLine="*winrm*")
| eval AlertType="WinRM_DirectTool"
| table _time, host, User, Image, CommandLine, AlertType)
OR
(sourcetype="WinEventLog:Microsoft-Windows-WinRM/Operational"
(EventCode=91 OR EventCode=168)
| eval AlertType="WinRM_SessionCreated"
| table _time, host, EventCode, AlertType)
)
| sort - _time Detects WinRM activity using Sysmon Event ID 1 (three patterns: wsmprovhost.exe child process spawning, PowerShell WinRM usage, winrs.exe tool execution) and WinRM Operational log events (Event ID 91: session created, Event ID 168: authentication succeeded). The AlertType field classifies the detection category.
Data Sources
Required Sourcetypes
False Positives & Tuning
- IT administrators using PowerShell remoting for legitimate remote management
- SCCM/Intune using WinRM for remote script execution
- Monitoring agents collecting data via WinRM
- Ansible using WinRM as its Windows transport layer
- Automated patch management using PowerShell remoting
Other platforms for T1021.006
Testing Methodology
Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Execute Remote Command via WinRM (Invoke-Command)
Expected signal: Sysmon Event ID 1: powershell.exe with Invoke-Command and ComputerName in command line. Sysmon Event ID 3: outbound TCP to 127.0.0.1:5985. On target: wsmprovhost.exe spawning child process (Get-Process execution). WinRM Operational Event ID 91.
- Test 2Enable WinRM on Remote Host via Registry
Expected signal: Sysmon Event ID 1: powershell.exe with Enable-PSRemoting. Sysmon Event ID 13 (Registry Value Set): changes to WinRM configuration registry keys under HKLM\SOFTWARE\Policies\Microsoft\Windows\WinRM. WinRM service start in System log.
- Test 3Execute Remote Command via winrs.exe
Expected signal: Sysmon Event ID 1: winrs.exe process creation with -r: and remote IP. Sysmon Event ID 3: network connection to 127.0.0.1:5985. On target: wsmprovhost.exe spawning cmd.exe with 'whoami & hostname'.
- Test 4Interactive WinRM Session via Enter-PSSession
Expected signal: Sysmon Event ID 1: powershell.exe with New-PSSession and ComputerName 127.0.0.1. Sysmon Event ID 3: TCP connection to 5985. WinRM Operational Events 6, 11, 15 (create, shell, command). ScriptBlock Log Event 4104 with Get-LocalUser.
References (8)
- https://attack.mitre.org/techniques/T1021/006/
- https://learn.microsoft.com/en-us/windows/win32/winrm/portal
- https://learn.microsoft.com/en-us/powershell/module/microsoft.wsman.management/
- https://github.com/Hackplayers/evil-winrm
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1021.006/T1021.006.md
- https://www.nccgroup.com/uk/about-us/newsroom-and-events/blogs/2021/january/chimera-apt-targeting-semiconductor-vendors/
- https://www.microsoft.com/security/blog/2023/09/14/peach-sandstorm-password-spray-campaigns-enable-intelligence-collection-at-high-value-targets/
- https://docs.microsoft.com/en-us/archive/blogs/jepayne/2014-02-03-lateral-movement-winrm
Unlock Pro Content
Get the full detection package for T1021.006 including response playbook, investigation guide, and atomic red team tests.