Detection rules › Elastic

Suspicious Large Script Execution via Shell Command

Source
github.com/elastic/protections-artifacts

Detects when a script interpreter or unsigned/untrusted binary executes an abnormally large shell command. Many different types of macOS malware will hardcode large shell or apple scripts and execute them via a shell command.

MITRE ATT&CK coverage

Telemetry coverage

Rule body

[rule]
description = """
Detects when a script interpreter or unsigned/untrusted binary executes an abnormally large shell command. Many
different types of macOS malware will hardcode large shell or apple scripts and execute them via a shell command.
"""
id = "2410cd1c-4f14-4db3-be70-16e86a37c9a9"
license = "Elastic License v2"
name = "Suspicious Large Script Execution via Shell Command"
os_list = ["macos"]
reference = [
    "https://www.sentinelone.com/blog/xcsset-malware-update-macos-threat-actors-prepare-for-life-without-python/",
]
version = "1.0.3"

query = '''
process where event.type == "start" and event.action == "exec" and (process.name in ("bash", "sh", "zsh", "dash", "csh", "tcsh", "ksh", "tclsh", "fish") or process.name like "tclsh*") and process.args == "-c" and process.command_line == null and process.args_count <= 4 and
 (process.parent.name like~ ("osascript", "python*", "node", "sh", "bash", "zsh", "dash", "csh", "tcsh", "ksh", "fish", "tclsh*") or (process.parent.code_signature.trusted == false or process.parent.code_signature.exists == false))
'''

min_endpoint_version = "8.11.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.002"
name = "AppleScript"
reference = "https://attack.mitre.org/techniques/T1059/002/"

[[threat.technique.subtechnique]]
id = "T1059.004"
name = "Unix Shell"
reference = "https://attack.mitre.org/techniques/T1059/004/"



[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"

[internal]
min_endpoint_version = "8.11.0"

Stages and Predicates

Stage 1: process

process where event.type == "start" and event.action == "exec" and (process.name in ("bash", "sh", "zsh", "dash", "csh", "tcsh", "ksh", "tclsh", "fish") or process.name like "tclsh*") and process.args == "-c" and process.command_line == null and process.args_count <= 4 and
 (process.parent.name like~ ("osascript", "python*", "node", "sh", "bash", "zsh", "dash", "csh", "tcsh", "ksh", "fish", "tclsh*") or (process.parent.code_signature.trusted == false or process.parent.code_signature.exists == false))

Indicators

These rows show field, operator, and value matches.