Detection rules › Splunk
Potential PowerShell Post-Exploitation Activity (Windows Event Log)
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
| Tactic | Techniques |
|---|---|
| Execution | T1059.001 Command and Scripting Interpreter: PowerShell |
| Discovery | T1082 System Information Discovery, T1087 Account Discovery |
References
Event coverage
| Provider | Event | Title |
|---|---|---|
| Security-Auditing | Event ID 4688 | A new process has been created. |
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.
| Field | Kind | Values |
|---|---|---|
EventCode | eq |
|
dc_process | gt |
|
parent_process_name | regex_match |
|
process | regex_match |
|
process_name | regex_match |
|
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.
| Stage | Term |
|---|---|
| 1 | TERM |
| 1 | "<EventID>4688<" |
| 1 | "powershell.exe" |
| 1 | "pwsh.exe" |
| 1 | "csc.exe" |
| 1 | "cvtres.exe" |
| 1 | ".cmdline" |