Detection: Windows Renamed Python Binary was Executed

Description

The following analytic identifies a Python process being executed where it's process name does not match it's original file name attribute. Processes that have been renamed and executed may be an indicator that an adversary is attempting to evade defenses or execute malicious code.

 1
 2| tstats `security_content_summariesonly`
 3  count min(_time) AS firstTime
 4        max(_time) AS lastTime
 5
 6FROM datamodel=Endpoint.Processes WHERE
 7
 8Processes.original_file_name IN (
 9        "py*",
10        "python*",
11        "ipyw*"
12)
13
14NOT Processes.process_name IN ("dwagent.exe", "WinUtils.exe")
15
16by Processes.action Processes.dest Processes.original_file_name Processes.parent_process
17   Processes.parent_process_exec Processes.parent_process_guid Processes.parent_process_id
18   Processes.parent_process_name Processes.parent_process_path
19   Processes.process Processes.process_exec Processes.process_guid
20   Processes.process_hash Processes.process_id Processes.process_integrity_level
21   Processes.process_name Processes.process_path
22   Processes.user Processes.user_id Processes.vendor_product
23
24
25| `drop_dm_object_name(Processes)`
26
27
28| eval original_file_name=lower(original_file_name)
29
30
31| regex original_file_name="(?i)^(?:py
32|pyw
33|python
34|pythonw
35|python32
36|python64
37|pythonw32
38|pythonw64
39|ipyw32
40|ipyw64
41|python3
42|pythonw3
43|python3\.\w+
44|pythonw3\.\w+)\.exe$"
45
46
47| regex process_name!="(?i)^(?:py
48|pyw
49|pip
50|pip3
51|python
52|pythonw
53|python32
54|python64
55|pythonw32
56|pythonw64
57|ipyw32
58|ipyw64
59|python3
60|pythonw3
61|python3\.\w+
62|pythonw3\.\w+
63|pip3\.\w+
64|idle3\.\w+)\.exe$"
65
66
67| `security_content_ctime(firstTime)`
68
69| `security_content_ctime(lastTime)`
70
71| `windows_renamed_python_binary_was_executed_filter`

Data Source

Name Platform Sourcetype Source
Sysmon EventID 1 Windows icon Windows 'XmlWinEventLog' 'XmlWinEventLog:Microsoft-Windows-Sysmon/Operational'
CrowdStrike ProcessRollup2 Other 'crowdstrike:events:sensor' 'crowdstrike'

Macros Used

Name Value
security_content_ctime convert timeformat="%Y-%m-%dT%H:%M:%S" ctime($field$)
windows_renamed_python_binary_was_executed_filter search *
windows_renamed_python_binary_was_executed_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

- MITRE ATT&CK
+ Kill Chain Phases
+ NIST
+ CIS
- Threat Actors
ID Technique Tactic
T1036.003 Rename Legitimate Utilities Stealth
T1059.006 Python Execution
Installation
Exploitation
DE.AE
CIS 10

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
Anomaly detections generate Intermediate Findings (Risk Events). They do not generate a Finding (Notable) directly.

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

Various Python implementations might have a different executable name, which could trigger false positives.

Associated Analytic Story

Intermediate Findings

Message Entity Field Entity Type Risk Score
Python binary [$original_file_name$] was renamed as [$process_path$] and later executed on [$dest$] dest system 20

Threat Objects

Field Type
process_name process_name

References

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