Detection rules › Elastic

Base64 Encoded String Execution via Osascript

Source
github.com/elastic/protections-artifacts

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.

Indicators

These rows show field, operator, and value matches.