Detection rules › YARA-L
W3WP Launching Encoded Powershell
Detects on the execution of an encoded powershell command with a parent process of w3wp.exe.
Known false positives
- Legitimate administrative actions to the specified URL should be rare. Some penetration testing activity could trigger this rule. In some cases, specific third party applications could generate similar requests, but this should be rare.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution |
References
Telemetry coverage
| Provider | Record / event type |
|---|---|
| Sysmon | Event ID 1: Process creation |
| Security-Auditing | Event ID 4688: A new process has been created. |
Rule body
// Copyright 2025 Google LLC. Licensed under Apache-2.0.
rule ttp_windows_w3wp_launching_encoded_powershell {
meta:
author = "Google Cloud Security"
rule_name = "W3WP Launching Encoded Powershell"
description = "Detects on the execution of an encoded powershell command with a parent process of w3wp.exe."
severity = "Medium"
tactic = "TA0002"
technique = "T1059.001"
false_positives = "Legitimate administrative actions to the specified URL should be rare. Some penetration testing activity could trigger this rule. In some cases, specific third party applications could generate similar requests, but this should be rare."
reference = "https://nvd.nist.gov/vuln/detail/CVE-2025-49706, https://research.eye.security/sharepoint-under-siege/"
rule_id = "mr_83daf64e-25e8-4b6b-8596-3adcc694e781"
events:
$e.metadata.event_type = "PROCESS_LAUNCH"
re.regex($e.principal.process.file.full_path, `(^|\\)w3wp\.exe$`) nocase
not re.regex($e.target.process.command_line, `\\Scripts\\CheckDiskSpace\.ps1'`) nocase
not re.regex($e.target.process.command_line, `DQAKACQARQByAHIAbwByAEEAYwB0AGkAbwBuAFAAcgBlAGYAZQByAGUAbgBjAGUAIAA9ACAAJwBTAHQAbwBwACcADQAKAFsAdgBlAHIAcwBpAG8AbgBdACQAbQBpAG4AaQBtAHUAbQBWAGUAcgBzAGkAbwBuACAAPQAgACcAMgAuADIALgAwACcADQAKAA0ACgAkAG0AIAA9ACAASQBtAHAAbwByAHQALQBNAG8AZAB1AGwAZQAgAEEAegAuAEEAYwBjAG8AdQBuAHQAcwAg`) nocase
not re.regex($e.target.process.command_line, `EncodedCommand JABQAG8AaQBuAHQAZQBlAFIAZQBzAG8AdQByAGMAZQBOAGEAbQBlACAAPQAgACcAVgBEAFAAUgB`) nocase
(
(
re.regex($e.target.process.file.full_path, `(^|\\)(pwsh|powershell)\.exe$`) nocase and
re.regex($e.target.process.command_line, `\s-(e|en|enc|enco|encodedcommand)\s`) nocase
) or
re.regex($e.target.process.command_line, `(pwsh|powershell).*\s-(e|en|enc|enco|encodedcommand)\s`) nocase
)
outcome:
$principal_hostname = $e.principal.hostname
$risk_score = 65
$vendor_name = array($e.metadata.vendor_name)
$product_name = $e.metadata.product_name
$victim_uid = $e.principal.asset.asset_id
$victim_name = $e.principal.asset.hostname
$victim_netid = array($e.principal.ip)
$adversary_uid = $e.principal.user.userid
$adversary_name = $e.principal.user.user_display_name
$adversary_netid = $e.principal.user.windows_sid
$tmp1 = max(
if($e.security_result.action != "BLOCK" and $e.security_result.action != "UNKNOWN_ACTION", 2)
)
$tmp2 = max(
if($e.security_result.action = "BLOCK", 1)
)
$result = arrays.index_to_str(strings.split("attempted,failed,succeeded,succeeded"), $tmp1 + $tmp2)
$result_time = $e.metadata.event_timestamp.seconds
$event_count = 1
condition:
$e
}
YARA-L rule structure
Condition
Fires when at least one $e event.
Events
$e
principal.process.file.full_path matches "(^|\\)w3wp\.exe$"target.process.command_line matches "\\Scripts\\CheckDiskSpace\.ps1'"target.process.command_line matches "DQAKACQARQByAHIAbwByAEEAYwB0AGkAbwBuAFAAcgBlAGYAZQByAGUAbgBjAGUAIAA9ACAAJwBTAHQAbwBwACcADQAKAFsAdgBlAHIAcwBpAG8AbgBdACQAbQBpAG4AaQBtAHUAbQBWAGUAcgBzAGkAbwBuACAAPQAgACcAMgAuADIALgAwACcADQAKAA0ACgAkAG0AIAA9ACAASQBtAHAAbwByAHQALQBNAG8AZAB1AGwAZQAgAEEAegAuAEEAYwBjAG8AdQBuAHQAcwAg"target.process.command_line matches "EncodedCommand JABQAG8AaQBuAHQAZQBlAFIAZQBzAG8AdQByAGMAZQBOAGEAbQBlACAAPQAgACcAVgBEAFAAUgB"target.process.file.full_path matches "(^|\\)(pwsh|powershell)\.exe$"target.process.command_line matches "\s-(e|en|enc|enco|encodedcommand)\s"target.process.command_line matches "(pwsh|powershell).*\s-(e|en|enc|enco|encodedcommand)\s"
Outcome
Outcome variables add context to a detection. When the rule generates an alert, $risk_score is displayed with it.
| Field | Expression |
|---|---|
principal_hostname | $e.principal.hostname |
risk_score | 65 |
vendor_name | array($e.metadata.vendor_name) |
product_name | $e.metadata.product_name |
victim_uid | $e.principal.asset.asset_id |
victim_name | $e.principal.asset.hostname |
victim_netid | array($e.principal.ip) |
adversary_uid | $e.principal.user.userid |
adversary_name | $e.principal.user.user_display_name |
adversary_netid | $e.principal.user.windows_sid |
tmp1 | max( if($e.security_result.action != "BLOCK" and $e.security_result.action != "UNKNOWN_ACTION", 2) ) |
tmp2 | max( if($e.security_result.action = "BLOCK", 1) ) |
result | arrays.index_to_str(strings.split("attempted,failed,succeeded,succeeded"), $tmp1 + $tmp2) |
result_time | $e.metadata.event_timestamp.seconds |
event_count | 1 |