Detection rules › Splunk

Invoke-Expression Command (Sysmon)

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

Detects when PowerShell Invoke-Expression is executed. -- Threat Group Association: Actinium/Gamaredon/Primitive Bear, Andariel, APT29/Nobelium/Cozy Bear, APT31, FIN7, FIN8, Lazarus, TA505, TA551, Turla (akaSecret Blizzard, KRYPTON, and UAC-0003), WinterVivern/UAC-0114, Winter Vivern, WIRTE, Wizard Spider

MITRE ATT&CK coverage

References

Event coverage

ProviderEventTitle
SysmonEvent ID 1Process creation

Rule body yaml

id: '1037.1051'
title: Invoke-Expression Command
description: 'Detects when PowerShell Invoke-Expression is executed. -- Threat Group
  Association: Actinium/Gamaredon/Primitive Bear, Andariel, APT29/Nobelium/Cozy Bear,
  APT31, FIN7, FIN8, Lazarus, TA505, TA551, Turla (akaSecret Blizzard, KRYPTON, and
  UAC-0003), WinterVivern/UAC-0114, Winter Vivern, WIRTE, Wizard Spider - Software
  Association: ALPHV/BlackCat, BadHatch, Bazar, Black Basta, Clop, Conti, Cring, IcedID,
  LV, Play, PowerShortShell, PurpleFox, PYSA/Mespinoza, Remcos, SamSam, SquirrelWaffle,
  Trickbot, XingLocker -- #TrendingThreat #Russia #Ukraine -- Atomics T1059.001 Test
  #1 Atomics T1059.001 Test #4 Atomics T1059.001 Test #5 Atomics T1059.001 Test #8
  Atomics T1059.001 Test #11 Atomics T1059.001 Test #13 Atomics T1135 Test #6 Atomics
  T1059.005 Test #2 Atomics T1059.005 Test #3 Atomics T1134.002 Test #2'
logic_format: Splunk
logic: '`get_endpoint_data` `get_endpoint_data_sysmon` EventCode=1 (TERM("invoke-expression")
  OR TERM("iex")) | table _time, host, user dest, direction, dvc, dvc_nt_host, event_id,
  eventtype, hashes, host, index, parent_process, parent_process_id, parent_process_name,
  parent_process_path, process, process_current_directory, process_id, process_name,
  process_path, signature_id, source, sourcetype, tag, user, user_id `group_events("host,
  process", 1)` '
techniques:
- execution:command and scripting interpreter:powershell
technique_id:
- T1059.001
data_category:
- Windows Sysmon
references:
- https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-expression?view=powershell-7.1
- https://www.fortinet.com/blog/threat-research/offense-and-defense-a-tale-of-two-sides-powershell
- https://www.cyber.gov.au/acsc/view-all-content/publications/securing-powershell-enterprise
- https://www.microsoft.com/security/blog/2022/02/04/actinium-targets-ukrainian-organizations/?utm_campaign=Threat%20Report%20Newsletter&utm_medium=email&_hsmi=203254280&_hsenc=p2ANqtz-_lmhDqWF4dK1aEuVSrgJUOHdLMvJ7ORkr-vdksakqAPIxGFhGLMHMGAUiX4y9HTdUyzYWBQlJ

Stages and Predicates

Stage 1: search

search EventCode=1 source="*" source IN ("WinEventLog:Microsoft-Windows-Sysmon/Operational", "XmlWinEventLog:Microsoft-Windows-Sysmon/Operational")

Stage 2: table

table _time, dest, direction, dvc, dvc_nt_host, event_id, eventtype, hashes, host, index, parent_process, parent_process_id, parent_process_name, parent_process_path, process, process_current_directory, process_id, process_name, process_path, signature_id, source, sourcetype, tag, user, user_id

Stage 3: bucket

bucket _time

Stage 4: stats

stats BY host, process, _time

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
EventCodeeq
  • 1 corpus 237 (splunk 224, kusto 13)

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
1"invoke-expression"
1"iex"