Shell Command Piped to Osascript via Shell Script


Description

Detects when shell commands are piped to osascript for execution. This technique can be used by adversaries to execute AppleScript commands indirectly through shell scripts.

Query · eql

sequence with maxspan = 10s
[process where event.type == "start" and event.action == "exec" and process.parent.name in ("bash", "sh", "zsh") and process.name == "osascript" and process.args_count == 1] by process.entity_id
[process where event.type == "start" and event.action == "exec" and process.name in ("bash", "sh", "zsh") and process.args == "-c"] by process.parent.entity_id
Raw source Shell Command Piped to Osascript via Shell Script · Elastic TOML
Esc
Published by elastic/protections-artifacts ↗, licensed under Elastic License 2.0 ↗. Reproduced here unmodified.
[rule]
description = """
Detects when shell commands are piped to osascript for execution. This technique can be used by adversaries to execute
AppleScript commands indirectly through shell scripts.
"""
id = "2b6eac2a-c533-463c-bcbb-098d40fe3854"
license = "Elastic License v2"
name = "Shell Command Piped to Osascript via Shell Script"
os_list = ["macos"]
version = "1.0.4"

query = '''
sequence with maxspan = 10s
[process where event.type == "start" and event.action == "exec" and process.parent.name in ("bash", "sh", "zsh") and process.name == "osascript" and process.args_count == 1] by process.entity_id
[process where event.type == "start" and event.action == "exec" and process.name in ("bash", "sh", "zsh") and process.args == "-c"] by process.parent.entity_id
'''

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.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.16.0"

Detection rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.