Detection rules › Elastic
AppleScript Decoded via Base64
Detects when AppleScript is executed followed by the execution of the Base64 binary with the decode option set. Several malware samples have been observed executing base64 encoded AppleScript in order to avoid detection.
MITRE ATT&CK coverage
Telemetry coverage
Rule body
[rule]
description = """
Detects when AppleScript is executed followed by the execution of the Base64 binary with the decode option set. Several
malware samples have been observed executing base64 encoded AppleScript in order to avoid detection.
"""
id = "9602ed93-b5cf-4397-ba37-6e752082847c"
license = "Elastic License v2"
name = "AppleScript Decoded via Base64"
os_list = ["macos"]
version = "1.0.8"
query = '''
sequence with maxspan=10s
[process where event.type == "start" and event.action == "exec" and process.parent.name == "osascript" and
(process.name in ("bash", "zsh", "sh", "dash", "csh", "tcsh", "ksh", "tclsh", "fish") or process.name like "tclsh*") and process.args == "-c"] by process.entity_id
[process where event.type == "start" and event.action == "exec" and (process.name in ("bash", "zsh", "sh", "dash", "csh", "tcsh", "ksh", "tclsh", "fish", "base64") or process.name like "tclsh*") and
process.command_line like~ "*base64*-d*"] by process.parent.entity_id
'''
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.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1027"
name = "Obfuscated Files or Information"
reference = "https://attack.mitre.org/techniques/T1027/"
[[threat.technique]]
id = "T1140"
name = "Deobfuscate/Decode Files or Information"
reference = "https://attack.mitre.org/techniques/T1140/"
[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"
[internal]
min_endpoint_version = "8.11.0"
Stages and Predicates
Ordered sequence: each step below must occur in order within 10s, correlated by process.entity_id, process.parent.entity_id.
Stage 1: process
[process where event.type == "start" and event.action == "exec" and process.parent.name == "osascript" and
(process.name in ("bash", "zsh", "sh", "dash", "csh", "tcsh", "ksh", "tclsh", "fish") or process.name like "tclsh*") and process.args == "-c"] by process.entity_id
Stage 2: process
[process where event.type == "start" and event.action == "exec" and (process.name in ("bash", "zsh", "sh", "dash", "csh", "tcsh", "ksh", "tclsh", "fish", "base64") or process.name like "tclsh*") and
process.command_line like~ "*base64*-d*"] by process.parent.entity_id
Indicators
These rows show field, operator, and value matches.
| Field | Kind | Values | Search |
|---|---|---|---|
event.action | eq |
| field:"EventType" kind:eq value:"exec" |
event.type | eq |
| field:"event.type" kind:eq value:"start" |
process.args | eq |
| field:"process.args" kind:eq value:"-c" |
process.command_line | wildcard |
| field:"CommandLine" kind:wildcard value:"*base64*-d*" |
process.name | in |
| field:"process_name" kind:in |
process.name | wildcard |
| field:"process_name" kind:wildcard value:"tclsh*" |
process.parent.name | eq |
| field:"parent_process_name" kind:eq value:"osascript" |