Detection rules › Splunk

Potential PowerShell Post-Exploitation Activity (Windows Event Log)

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

Threat actors may perform post-exploitation activities using PowerShell scripts such as ADRecon. When running ADRecon, PowerShell launches child processes to compile and execute payloads and creates several .cmdline files in AppData\Local\Temp directories. This use case detects PowerShell-invoked compilations involving csc.exe and cvtres.exe referencing multiple .cmdline files from temp directories within a 5 minute time period. This may that a malicious script like ADRecon has been executed, regardless of the script title name or cmdlets invoked

MITRE ATT&CK coverage

References

Event coverage

Rule body yaml

id: '27535.50073'
title: Potential PowerShell Post-Exploitation Activity
description: 'Threat actors may perform post-exploitation activities using PowerShell
  scripts such as ADRecon. When running ADRecon, PowerShell launches child processes
  to compile and execute payloads and creates several .cmdline files in AppData\Local\Temp
  directories. This use case detects PowerShell-invoked compilations involving csc.exe
  and cvtres.exe referencing multiple .cmdline files from temp directories within
  a 5 minute time period. This may that a malicious script like ADRecon has been executed,
  regardless of the script title name or cmdlets invoked. Atomics T1087.002 Test #4'
logic_format: Splunk
logic: '`get_endpoint_data` `get_endpoint_data_winevent` (TERM(EventCode=4688) OR
  "<EventID>4688<" OR Type=Process) ("powershell.exe" OR "pwsh.exe") ("csc.exe" OR
  "cvtres.exe") ".cmdline" | regex parent_process_name="(?i)(powershell|pwsh)\.exe"|
  regex process_name="(?i)(csc|cvtres)\.exe"| regex process="(?i)\x5cAppData\x5cLocal\x5cTemp.+\.cmdline"
  | table _time, host, user process, parent_process_name, event_count | bin span=300s
  | stats values(*) as * by _time, host | eventstats dc(process) as dc_process by
  host, _time| where dc_process > 3 '
techniques:
- execution:command and scripting interpreter:powershell
- discovery:account discovery
- discovery:system information discovery
technique_id:
- T1059.001
- T1087
- T1082
data_category:
- Process command-line parameters
- Windows event logs
references:
- https://github.com/sense-of-security/ADRecon/tree/master
- https://www.dnif.it/en/blog/strategies-to-detect-post-exploitation-active-directory-reconnaissance
- https://symantec-enterprise-blogs.security.com/blogs/threat-intelligence/ransomware-hive-conti-avoslocker

Stages and Predicates

Stage 1: search

`get_endpoint_data` `get_endpoint_data_winevent` (TERM(EventCode=4688) OR "<EventID>4688<" OR Type=Process) ("powershell.exe" OR "pwsh.exe") ("csc.exe" OR "cvtres.exe") ".cmdline"

Stage 2: regex

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

Stage 3: regex

| regex process_name="(?i)(csc|cvtres)\.exe"

Stage 4: regex

| regex process="(?i)\x5cAppData\x5cLocal\x5cTemp.+\.cmdline"

Stage 5: table

| table _time, host, user process, parent_process_name, event_count

Stage 6: bucket

| bin span=300s

Stage 7: stats

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

Stage 8: eventstats

| eventstats dc(process) as dc_process by host, _time

Stage 9: where

| where dc_process > 3

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
  • 4688 corpus 313 (splunk 283, kusto 30)
dc_processgt
  • 3 corpus 4 (splunk 4)
parent_process_nameregex_match
  • "(?i)(powershell|pwsh).exe" corpus 2 (splunk 2)
processregex_match
  • "(?i)\x5cAppData\x5cLocal\x5cTemp.+.cmdline" corpus 2 (splunk 2)
process_nameregex_match
  • "(?i)(csc|cvtres).exe" corpus 2 (splunk 2)

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
1"<EventID>4688<"
1"powershell.exe"
1"pwsh.exe"
1"csc.exe"
1"cvtres.exe"
1".cmdline"