Detection rules › Splunk

Suspicious Executable by Powershell (EDR)

Group by
_time, host
Source
github.com/anvilogic-forge/armory

Detect when an executable has been launched by powershell and similar processes. Such as powershell cscript or cmd and similar processes spawning cmd.exe, cscript rundll32 and similar processes being a child process of powershell

MITRE ATT&CK coverage

References

Event coverage

Rule body yaml

id: '1041.12022'
title: Suspicious Executable by Powershell
description: 'Detect when an executable has been launched by powershell and similar
  processes. Such as powershell cscript or cmd and similar processes spawning cmd.exe,
  cscript rundll32 and similar processes being a child process of powershell. - Threat
  Actor Association: APT29/Nobelium/Cozy Bear, APT34/OilRig, APT41, APT43, FIN7, Flax
  Typhoon, Lancefly, MuddyWater, RedEyes - Software Association: Bazarloader, Blackbyte,
  IcedID, Qakbot/Qbot - #TrendingThreat #Russia #Ukraine'
logic_format: Splunk
logic: ' `get_endpoint_data` `get_endpoint_data_edr` ((event_type IN ("childproc","netconn","proc"))
  OR (TERM(ProcessRollup2) OR Type=Process) OR TERM(DeviceProcessEvents)) "powershell.exe"
  ("cmd.exe" OR "services.exe" OR "dllhost.exe" OR "rundll32.exe" OR "cscript.exe"
  OR "mshta.exe") | regex parent_process_name="(?i)(powershell\.exe)" | regex process_path="(?i)((cmd)|(services)|(dllhost)|(rundll32)|(cscript)|(mshta))\.exe"
  | table _time, host, user event_id, parent_*, process_*, process, signature_id,
  src_*, dest_* | bin span=1s | stats values(*) as * by _time, host | where isnotnull(user)
  `hec_collect`'
techniques:
- execution:command and scripting interpreter:powershell
- execution:command and scripting interpreter:windows command shell
technique_id:
- T1059.001
- T1059.003
data_category:
- Process command-line parameters
- EDR Logs
references:
- https://docs.broadcom.com/doc/increased-use-of-powershell-in-attacks-16-en
- https://www.clearskysec.com/wp-content/uploads/2018/11/MuddyWater-Operations-in-Lebanon-and-Oman.pdf

Stages and Predicates

Stage 1: search

`get_endpoint_data` `get_endpoint_data_edr` ((event_type IN ("childproc","netconn","proc")) OR (TERM(ProcessRollup2) OR Type=Process) OR TERM(DeviceProcessEvents)) "powershell.exe" ("cmd.exe" OR "services.exe" OR "dllhost.exe" OR "rundll32.exe" OR "cscript.exe" OR "mshta.exe")

Stage 2: regex

| regex parent_process_name="(?i)(powershell\.exe)"

Stage 3: regex

| regex process_path="(?i)((cmd)|(services)|(dllhost)|(rundll32)|(cscript)|(mshta))\.exe"

Stage 4: table

| table _time, host, user event_id, parent_*, process_*, process, signature_id, src_*, dest_*

Stage 5: bucket

| bin span=1s

Stage 6: stats

| stats values(*) as * by _time, host

Stage 7: where

| where isnotnull(user) `hec_collect`

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.

FieldKindValues
event_typein
  • "childproc"
  • "netconn"
  • "proc"
parent_process_nameregex_match
  • "(?i)(powershell.exe)" corpus 3 (splunk 3)
process_pathregex_match
  • "(?i)((cmd)|(services)|(dllhost)|(rundll32)|(cscript)|(mshta)).exe"
useris_not_null
  • (no value, null check)

Search terms

Bare-string tokens in the SPL search body. Splunk matches each token against _raw (the untyped raw event text) anywhere it appears, not against a specific field. These don't surface in the Indicators table because they aren't predicates on a known field.

StageTerm
1TERM
1ProcessRollup2
1TERM
1DeviceProcessEvents
1"powershell.exe"
1"cmd.exe"
1"services.exe"
1"dllhost.exe"
1"rundll32.exe"
1"cscript.exe"
1"mshta.exe"