Detection: MacOS Osascript Executing Interactive Shell

Description

This analytic detects the macOS osascript utility being used with an interactive Bash invocation, identified by the presence of "bash -i" in the command line. Adversaries may abuse osascript and AppleScript's shell execution capabilities to launch interactive shells, establish remote access, or execute post-exploitation commands.

 1
 2| tstats `security_content_summariesonly`
 3  count min(_time) as firstTime
 4        max(_time) as lastTime
 5
 6FROM datamodel=Endpoint.Processes WHERE
 7
 8Processes.process_name="osascript"
 9Processes.process="*bash *"
10Processes.process="* -i*"
11
12BY Processes.action Processes.dest Processes.parent_process Processes.parent_process_exec
13    Processes.parent_process_guid Processes.parent_process_id
14    Processes.parent_process_name Processes.parent_process_path
15    Processes.process Processes.process_exec Processes.process_guid
16    Processes.process_hash Processes.process_id Processes.process_integrity_level
17    Processes.process_name Processes.process_path Processes.user
18    Processes.user_id Processes.vendor_product
19
20
21| `drop_dm_object_name(Processes)`
22
23| `security_content_ctime(firstTime)`
24
25| `security_content_ctime(lastTime)`
26
27| `macos_osascript_executing_interactive_shell_filter`

Data Source

Name Platform Sourcetype Source
Osquery Results Other 'osquery:results' 'osquery'

Macros Used

Name Value
security_content_summariesonly summariesonly=summariesonly_config allow_old_summaries=oldsummaries_config fillnull_value=fillnull_config``
macos_osascript_executing_interactive_shell_filter search *
macos_osascript_executing_interactive_shell_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.

Annotations

- MITRE ATT&CK
+ Kill Chain Phases
+ NIST
+ CIS
- Threat Actors
ID Technique Tactic
T1059.002 AppleScript Execution
T1059.004 Unix Shell Execution
Installation
DE.AE
CIS 10

Default Configuration

This detection is configured by default in Splunk Enterprise Security to run with the following settings:

Setting Value
Disabled true
Cron Schedule 0 * * * *
Earliest Time -70m@m
Latest Time -10m@m
Schedule Window auto
Creates Finding (Notable) No
Creates Intermediate Finding (Risk Event) Yes
Anomaly detections generate Intermediate Findings (Risk Events). They do not generate a Finding (Notable) directly.

Implementation

This detection uses osquery and endpoint security on MacOS. Follow the link in references, which describes how to setup process auditing in MacOS with endpoint security and osquery. Also the TA-OSquery must be deployed across your indexers and universal forwarders in order to have the osquery data populate the data models.

Known False Positives

Legitimate administrative scripts, MDM workflows, software deployment tools, developer automation, or support utilities may use osascript to invoke an interactive shell.

Associated Analytic Story

Intermediate Findings

Message Entity Field Entity Type Risk Score
The Osascript utility with the command line [$process$] was observed on [$dest$] executing an interactive Bash command line. dest system 20

Threat Objects

Field Type
process process

References

Detection Testing

Test Type Status Dataset Source Sourcetype
Validation Passing N/A N/A N/A
Unit Passing Dataset osquery osquery:results
Integration ✅ Passing Dataset osquery osquery:results

Replay any dataset to Splunk Enterprise by using our replay.py tool or the UI. Alternatively you can replay a dataset into a Splunk Attack Range


Source: GitHub |

Version: 1