Detection rules › YARA-L
W3WP Launching Encoded Powershell
Detects on the execution of an encoded powershell command with a parent process of w3wp.exe.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | T1059.001 Command and Scripting Interpreter: PowerShell |
References
Event coverage
| Provider | Event | Title |
|---|---|---|
| Sysmon | Event ID 1 | Process creation |
| Security-Auditing | Event ID 4688 | A new process has been created. |
Rule body yaral
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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
}
Detection logic
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
Fields the detection emits on a match. $risk_score drives alerting; Chronicle surfaces the rest on the detection.
| 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 |