ttp_windows_w3wp_launching_encoded_powershell


Description

Detects on the execution of an encoded powershell command with a parent process of w3wp.exe.

Query · yara_l

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
Raw source ttp_windows_w3wp_launching_encoded_powershell · YARA-L
Esc
Published by chronicle/detection-rules ↗, licensed under Apache 2.0 ↗. Reproduced here unmodified.
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 rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.