Detection rules › Elastic

Suspicious Executable File Creation via Python

Time window
15s
Sequence by
process.entity_id
Source
github.com/elastic/protections-artifacts

Detects Python processes creating executable files with Mach-O headers in suspicious directories like /tmp or /Users/Shared. This indicates malicious Python scripts dropping payloads for execution, commonly observed in APT campaigns.

MITRE ATT&CK coverage

Telemetry coverage

Rule body

[rule]
description = """
Detects Python processes creating executable files with Mach-O headers in suspicious directories like /tmp or
/Users/Shared. This indicates malicious Python scripts dropping payloads for execution, commonly observed in APT
campaigns.
"""
id = "d9f6974d-1545-4575-88e8-d166a7a526db"
license = "Elastic License v2"
name = "Suspicious Executable File Creation via Python"
os_list = ["macos"]
reference = [
    "https://unit42.paloaltonetworks.com/slow-pisces-new-custom-malware/",
    "https://slowmist.medium.com/cryptocurrency-apt-intelligence-unveiling-lazarus-groups-intrusion-techniques-a1a6efda7d34",
]
version = "1.0.3"

query = '''
sequence by process.entity_id with maxspan=15s
[process where event.type == "start" and event.action == "exec" and process.name like~ "python*" and process.args_count == 2]
[file where event.action == "modification" and
 file.Ext.header_bytes like~ ("cffaedfe*", "cafebabe*") and
 file.path like ("/Users/Shared/*", "/tmp/*", "/private/tmp/*", "/Users/*/Public/*") and
 not file.extension in ("dylib", "so")]
'''

min_endpoint_version = "8.16.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[actions]]
action = "kill_process"
field = "process.parent.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.006"
name = "Python"
reference = "https://attack.mitre.org/techniques/T1059/006/"



[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1105"
name = "Ingress Tool Transfer"
reference = "https://attack.mitre.org/techniques/T1105/"


[threat.tactic]
id = "TA0011"
name = "Command and Control"
reference = "https://attack.mitre.org/tactics/TA0011/"

[internal]
min_endpoint_version = "8.16.0"

Stages and Predicates

Ordered sequence: each step below must occur in order within 15s, correlated by process.entity_id.

Stage 1: process

[process where event.type == "start" and event.action == "exec" and process.name like~ "python*" and process.args_count == 2]

Stage 2: file

[file where event.action == "modification" and
 file.Ext.header_bytes like~ ("cffaedfe*", "cafebabe*") and
 file.path like ("/Users/Shared/*", "/tmp/*", "/private/tmp/*", "/Users/*/Public/*") and
 not file.extension in ("dylib", "so")]

Exclusions

The rule actively suppresses these predicates.

Indicators

These rows show field, operator, and value matches.