| ID | Technique | Tactic |
|---|---|---|
| T1059.002 | AppleScript | Execution |
| T1059.007 | JavaScript | Execution |
Detection: MacOS Osascript Executing JavaScript Code With ObjC
Description
This analytic detects the macOS osascript utility executing JavaScript for Automation (JXA) code, identified by the "-l JavaScript" interpreter flag, with references to the Objective-C bridge. Adversaries may abuse JXA and Objective-C APIs to interact with macOS applications, access native system functionality, execute commands, or perform post-exploitation activity.
Search
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="*-l *"
10Processes.process="* JavaScript*"
11Processes.process="*ObjC.*"
12
13BY Processes.action Processes.dest Processes.parent_process Processes.parent_process_exec
14 Processes.parent_process_guid Processes.parent_process_id
15 Processes.parent_process_name Processes.parent_process_path
16 Processes.process Processes.process_exec Processes.process_guid
17 Processes.process_hash Processes.process_id Processes.process_integrity_level
18 Processes.process_name Processes.process_path Processes.user
19 Processes.user_id Processes.vendor_product
20
21
22| `drop_dm_object_name(Processes)`
23
24| `security_content_ctime(firstTime)`
25
26| `security_content_ctime(lastTime)`
27
28| `macos_osascript_executing_javascript_code_with_objc_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_javascript_code_with_objc_filter | search * |
macos_osascript_executing_javascript_code_with_objc_filter is an empty macro by default. It allows the user to filter out any results (false positives) without editing the SPL.
Annotations
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 |
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
Scripts that legitimately invoke utility Osascript with JavaScript for automation or system management.
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 JXA code with Objective-C bridge references. | dest | system | 30 |
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