| ID | Technique | Tactic |
|---|---|---|
| T1027.010 | Command Obfuscation | Stealth |
| T1059.003 | Windows Command Shell | Execution |
| T1070.004 | File Deletion | Stealth |
Detection: Windows CMD Evasive Patterns Through Native Commands
Description
The following analytic detects cmd.exe being used to evade defenses with nothing but built-in commands, a pattern frequently seen in ClickFix-style social engineering and malware loader activity. Adversaries abuse native cmd.exe features such as call combined with variable assignment to assemble commands piece by piece, hiding the real payload from static inspection and string-based detections. They also chain native utilities such as timeout and del to erase the dropped executable shortly after it has run, which removes evidence and complicates forensic analysis. Because these techniques need no additional tooling, they let attackers blend into routine command shell activity. If confirmed malicious, this could indicate a staged loader concealing its intent or cleaning up after execution.
Search
1
2| tstats `security_content_summariesonly`
3 count min(_time) as firstTime
4 max(_time) as lastTime
5
6FROM datamodel=Endpoint.Processes WHERE
7
8(
9 Processes.process_name=cmd.exe
10 OR
11 Processes.original_file_name=Cmd.Exe
12)
13Processes.process IN ("*call *", "*timeout *")
14NOT Processes.user IN ("SYSTEM", "*\\SYSTEM")
15
16by Processes.action Processes.dest Processes.original_file_name
17 Processes.parent_process Processes.parent_process_exec Processes.parent_process_guid
18 Processes.parent_process_id Processes.parent_process_name Processes.parent_process_path
19 Processes.process Processes.process_exec Processes.process_guid Processes.process_hash
20 Processes.process_id Processes.process_integrity_level Processes.process_name Processes.process_path
21 Processes.user Processes.user_id Processes.vendor_product
22
23
24| `drop_dm_object_name(Processes)`
25
26
27| eval process_lower=lower(process)
28
29
30| eval call_set_obfuscation=if(
31 like(process_lower, "%call %")
32 AND match(process, "(?i)set\\s+[\\x22\\x27]?[\\w\\-\\_]+\\s?\\="), 1, 0)
33
34
35| eval timeout_self_deletion=if(
36 like(process_lower, "%timeout %")
37 AND like(process_lower, "%del %")
38 AND (like(process_lower, "% /f%") OR like(process_lower, "% /q%"))
39 AND like(process_lower, "% exit%"), 1, 0)
40
41
42| where call_set_obfuscation=1 OR timeout_self_deletion=1
43
44
45| fields - process_lower
46
47
48| `security_content_ctime(firstTime)`
49
50| `security_content_ctime(lastTime)`
51
52| `windows_cmd_evasive_patterns_through_native_commands_filter`
Data Source
| Name | Platform | Sourcetype | Source |
|---|---|---|---|
| CrowdStrike ProcessRollup2 | Other | 'crowdstrike:events:sensor' |
'crowdstrike' |
| Windows Event Log Security 4688 | 'XmlWinEventLog' |
'XmlWinEventLog:Security' |
|
| Sysmon EventID 1 | 'XmlWinEventLog' |
'XmlWinEventLog:Microsoft-Windows-Sysmon/Operational' |
Macros Used
| Name | Value |
|---|---|
| security_content_ctime | convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$) |
| windows_cmd_evasive_patterns_through_native_commands_filter | search * |
windows_cmd_evasive_patterns_through_native_commands_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.
Annotations
Default Configuration
This detection is configured by default in Splunk Enterprise Security to run with the following settings:
| Setting | Value |
|---|---|
| Disabled | true |
| Cron Schedule | 0 * * * * |
| Earliest Time | -70m@m |
| Latest Time | -10m@m |
| Schedule Window | auto |
| Creates Finding (Notable) | No |
| Creates Intermediate Finding (Risk Event) | Yes |
Implementation
The detection is based on data that originates from Endpoint Detection and Response (EDR) agents. These agents are designed to provide security-related telemetry from the endpoints where the agent is installed.
To implement this search, you must ingest logs that contain the process GUID, process name, and parent process.
Additionally, you must ingest complete command-line executions.
These logs must be processed using the appropriate Splunk Technology Add-ons that are specific to the EDR product.
The logs must also be mapped to the Processes node of the Endpoint data model.
Use the Splunk Common Information Model (CIM) to normalize the field
names and speed up the data modeling process.
Known False Positives
Legitimate batch scripts and installers may use call with variable assignment, or may delete themselves after a delay using timeout and del. Filter by parent process, user or script path as needed.
Associated Analytic Story
Intermediate Findings
| Message | Entity Field | Entity Type | Risk Score |
|---|---|---|---|
| Evasive cmd.exe command line [$process$] was executed by [$parent_process_name$] on endpoint [$dest$] by user [$user$]. | dest | system | 30 |
| Evasive cmd.exe command line [$process$] was executed by [$parent_process_name$] on endpoint [$dest$] by user [$user$]. | user | user | 30 |
Threat Objects
| Field | Type |
|---|---|
| parent_process_name | parent_process_name |
| process | process |
References
-
https://www.huntress.com/blog/clickfix-castleloader-backgroundfix
-
https://www.esentire.com/blog/amatera-stealer-4-0-2-beta-whats-new-in-this-variant
Detection Testing
| Test Type | Status | Dataset | Source | Sourcetype |
|---|---|---|---|---|
| Validation | ✅ Passing | N/A | N/A | N/A |
| Unit | ✅ Passing | Dataset | XmlWinEventLog:Microsoft-Windows-Sysmon/Operational |
XmlWinEventLog |
| Integration | ✅ Passing | Dataset | XmlWinEventLog:Microsoft-Windows-Sysmon/Operational |
XmlWinEventLog |
Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI.
Alternatively you can replay a dataset into a Splunk Attack Range
Source: GitHub |
Version: 1