Skip to content
Threat Feed
medium advisory

Incoming Execution via WinRM Remote Shell

This rule detects incoming execution via Windows Remote Management (WinRM) remote shell on a target host, which could be an indication of lateral movement by monitoring network traffic on ports 5985 or 5986 and processes initiated by WinRM.

Windows Remote Management (WinRM) is a protocol that allows for remote management and execution of commands on Windows machines. While beneficial for legitimate administrative tasks, adversaries can exploit WinRM for lateral movement by executing commands remotely. This detection rule identifies suspicious activity by monitoring network traffic on specific ports and processes initiated by WinRM (winrshost.exe), flagging potential unauthorized remote executions. The rule is designed for data generated by Elastic Defend, but also supports SentinelOne Cloud Funnel and Sysmon event logs. This detection can help identify attackers moving laterally within a Windows environment.

Attack Chain

  1. The attacker gains initial access to a machine within the network (e.g., via phishing or exploiting a vulnerability).
  2. The attacker uses this compromised machine to scan the network for potential targets with WinRM enabled.
  3. The attacker attempts to authenticate to a target machine using stolen credentials or by exploiting a vulnerability in WinRM.
  4. Upon successful authentication, the attacker establishes a WinRM session to the target machine over ports 5985 (HTTP) or 5986 (HTTPS).
  5. The attacker executes malicious commands on the target machine using the WinRM remote shell, often leveraging winrshost.exe.
  6. The executed commands may include reconnaissance activities (e.g., whoami, net user), privilege escalation attempts, or malware deployment.
  7. The attacker may use the compromised target to pivot to other systems, repeating the process and expanding their foothold.
  8. The final objective is typically data exfiltration, system compromise, or deployment of ransomware.

Impact

Successful exploitation via WinRM can lead to unauthorized access to sensitive data, system compromise, and lateral movement within the network. Attackers can leverage WinRM to execute arbitrary commands, deploy malware, and ultimately achieve their objectives, such as data theft or ransomware deployment. The impact can range from individual system compromise to widespread network breaches, depending on the attacker’s goals and the organization’s security posture.

Recommendation

  • Enable Sysmon process creation (Event ID 1) and network connection (Event ID 3) logging to provide the necessary data for the Sigma rules.
  • Deploy the Sigma rule Detect Incoming WinRM Remote Shell Execution via Network Connection to identify suspicious network connections on ports 5985 and 5986.
  • Deploy the Sigma rule Detect Suspicious WinRM Processes to detect suspicious processes spawned by winrshost.exe.
  • Review and whitelist known administrative IP addresses or users to reduce false positives as noted in the rule documentation.
  • Implement network segmentation to limit the ability of threats to move laterally across the network as described in the remediation steps.

Detection coverage 2

Detect Incoming WinRM Remote Shell Execution via Network Connection

medium

Detects incoming network connections on WinRM ports (5985, 5986) to identify potential remote shell execution.

sigma tactics: lateral_movement techniques: T1021.006 sources: network_connection, windows

Detect Suspicious WinRM Processes

medium

Detects suspicious processes spawned by winrshost.exe, indicating potential remote command execution.

sigma tactics: execution, lateral_movement techniques: T1021.006, T1059.001 sources: process_creation, windows

Detection queries are kept inside the platform. Get full rules →