Detection rules › Elastic
Base64 Encoded String Execution via Osascript
Detects when Osascript executes AppleScript containing a base64 encoded string. Many stealer samples execute AppleScript and some encode the script using base64 in order to avoid detection.
MITRE ATT&CK coverage
Telemetry coverage
Rule body
[rule]
description = """
Detects when Osascript executes AppleScript containing a base64 encoded string. Many stealer samples execute AppleScript
and some encode the script using base64 in order to avoid detection.
"""
id = "32b43493-dd69-47b3-ad63-34242aeebe39"
license = "Elastic License v2"
name = "Base64 Encoded String Execution via Osascript"
os_list = ["macos"]
version = "1.0.7"
query = '''
process where event.type == "start" and event.action == "exec" and process.name == "osascript" and
process.args == "-e" and
process.args regex~ """.*[A-Za-z0-9\+\/]{30,}\={0,2}.*""" and
process.command_line : "*base64*" and
not process.parent.code_signature.team_id == "9BNSXJN65R" and
not process.Ext.effective_parent.executable like "/Applications/Docker.app/Contents/MacOS/com.docker.backend"
'''
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.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.16.0"
Stages and Predicates
Stage 1: process
process where event.type == "start" and event.action == "exec" and process.name == "osascript" and
process.args == "-e" and
process.args regex~ """.*[A-Za-z0-9\+\/]{30,}\={0,2}.*""" and
process.command_line : "*base64*" and
not process.parent.code_signature.team_id == "9BNSXJN65R" and
not process.Ext.effective_parent.executable like "/Applications/Docker.app/Contents/MacOS/com.docker.backend"
Exclusions
The rule actively suppresses these predicates.
| Field | Kind | Excluded values | Search |
|---|---|---|---|
process.Ext.effective_parent.executable | eq | /Applications/Docker.app/Contents/MacOS/com.docker.backend | excludes:process.Ext.effective_parent.executable field:"process.Ext.effective_parent.executable" value:"/Applications/Docker.app/Contents/MacOS/com.docker.backend" |
process.parent.code_signature.team_id | eq | 9BNSXJN65R | excludes:process.parent.code_signature.team_id field:"process.parent.code_signature.team_id" value:"9BNSXJN65R" |
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:"-e" |
process.args | regex_match |
| field:"process.args" kind:regex_match value:".*[A-Za-z0-9+\/]{30,}\={0,2}.*" |
process.command_line | wildcard |
| field:"CommandLine" kind:wildcard value:"*base64*" |
process.name | eq |
| field:"process_name" kind:eq value:"osascript" |