agentic-threat-hunting-framework 0.2.3__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {agentic_threat_hunting_framework-0.2.3.dist-info → agentic_threat_hunting_framework-0.3.0.dist-info}/METADATA +38 -40
- agentic_threat_hunting_framework-0.3.0.dist-info/RECORD +51 -0
- athf/__version__.py +1 -1
- athf/cli.py +7 -2
- athf/commands/__init__.py +4 -0
- athf/commands/agent.py +452 -0
- athf/commands/context.py +6 -9
- athf/commands/env.py +2 -2
- athf/commands/hunt.py +3 -3
- athf/commands/init.py +45 -0
- athf/commands/research.py +530 -0
- athf/commands/similar.py +5 -5
- athf/core/research_manager.py +419 -0
- athf/core/web_search.py +340 -0
- athf/data/__init__.py +19 -0
- athf/data/docs/CHANGELOG.md +147 -0
- athf/data/docs/CLI_REFERENCE.md +1797 -0
- athf/data/docs/INSTALL.md +594 -0
- athf/data/docs/README.md +31 -0
- athf/data/docs/environment.md +256 -0
- athf/data/docs/getting-started.md +419 -0
- athf/data/docs/level4-agentic-workflows.md +480 -0
- athf/data/docs/lock-pattern.md +149 -0
- athf/data/docs/maturity-model.md +400 -0
- athf/data/docs/why-athf.md +44 -0
- athf/data/hunts/FORMAT_GUIDELINES.md +507 -0
- athf/data/hunts/H-0001.md +453 -0
- athf/data/hunts/H-0002.md +436 -0
- athf/data/hunts/H-0003.md +546 -0
- athf/data/hunts/README.md +231 -0
- athf/data/integrations/MCP_CATALOG.md +45 -0
- athf/data/integrations/README.md +129 -0
- athf/data/integrations/quickstart/splunk.md +162 -0
- athf/data/knowledge/hunting-knowledge.md +2375 -0
- athf/data/prompts/README.md +172 -0
- athf/data/prompts/ai-workflow.md +581 -0
- athf/data/prompts/basic-prompts.md +316 -0
- athf/data/templates/HUNT_LOCK.md +228 -0
- agentic_threat_hunting_framework-0.2.3.dist-info/RECORD +0 -23
- {agentic_threat_hunting_framework-0.2.3.dist-info → agentic_threat_hunting_framework-0.3.0.dist-info}/WHEEL +0 -0
- {agentic_threat_hunting_framework-0.2.3.dist-info → agentic_threat_hunting_framework-0.3.0.dist-info}/entry_points.txt +0 -0
- {agentic_threat_hunting_framework-0.2.3.dist-info → agentic_threat_hunting_framework-0.3.0.dist-info}/licenses/LICENSE +0 -0
- {agentic_threat_hunting_framework-0.2.3.dist-info → agentic_threat_hunting_framework-0.3.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
---
|
|
2
|
+
hunt_id: H-0001
|
|
3
|
+
title: macOS Data Collection via AppleScript Detection
|
|
4
|
+
status: completed
|
|
5
|
+
date: 2025-11-19
|
|
6
|
+
hunter: [Your Name]
|
|
7
|
+
platform: [macOS]
|
|
8
|
+
tactics: [collection]
|
|
9
|
+
techniques: [T1005, T1059.002, T1555.003]
|
|
10
|
+
data_sources: [macOS Unified Logging, EDR, File Access Logs]
|
|
11
|
+
related_hunts: []
|
|
12
|
+
findings_count: 3
|
|
13
|
+
true_positives: 1
|
|
14
|
+
false_positives: 1
|
|
15
|
+
customer_deliverables: []
|
|
16
|
+
tags: [macos, applescript, information-stealer, cookies, safari, notes, atomic-stealer]
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# H-0001: macOS Data Collection via AppleScript Detection
|
|
20
|
+
|
|
21
|
+
**Hunt Metadata**
|
|
22
|
+
|
|
23
|
+
- **Date:** 2025-11-19
|
|
24
|
+
- **Hunter:** [Your Name]
|
|
25
|
+
- **Status:** Completed
|
|
26
|
+
- **MITRE ATT&CK:** T1005 - Data from Local System
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## LEARN: Prepare the Hunt
|
|
31
|
+
|
|
32
|
+
### Hypothesis Statement
|
|
33
|
+
|
|
34
|
+
Adversaries use AppleScript to collect sensitive user data on macOS systems. You can observe this activity when osascript processes run “duplicate file” commands or when non-browser processes access Safari cookie files, Notes databases, or large batches of user documents. Adversaries typically stage the collected data in temporary directories such as /tmp or /var/folders within short timeframes.
|
|
35
|
+
|
|
36
|
+
### Threat Context
|
|
37
|
+
|
|
38
|
+
Atomic Stealer and similar macOS information stealers use AppleScript commands to collect sensitive data from infected systems.. This behavior maps to **T1005 - Data from Local System** under the **Collection** tactic (TA0009).
|
|
39
|
+
|
|
40
|
+
The malware targets high-value data through automated file duplication:
|
|
41
|
+
|
|
42
|
+
**Safari Cookies Theft:**
|
|
43
|
+
|
|
44
|
+
- Target: `~/Library/Cookies/Cookies.binarycookies`
|
|
45
|
+
- Method: `duplicate file "Cookies.binarycookies" of folder safariFolder to folder baseFolderPath with replacing`
|
|
46
|
+
- Value: Session tokens, authentication cookies for credential theft
|
|
47
|
+
|
|
48
|
+
**Notes Application Data:**
|
|
49
|
+
|
|
50
|
+
- Targets: `NoteStore.sqlite`, `NoteStore.sqlite-shm`, `NoteStore.sqlite-wal`
|
|
51
|
+
- Location: `~/Library/Group Containers/group.com.apple.notes/`
|
|
52
|
+
- Value: Personal notes may contain passwords, API keys, sensitive information
|
|
53
|
+
|
|
54
|
+
**Document Collection:**
|
|
55
|
+
|
|
56
|
+
- Targets: Desktop and Documents directories
|
|
57
|
+
- Filtering: Specific extensions (pdf, docx, txt, xlsx) and file size limits (≤50KB)
|
|
58
|
+
- Pattern: Recursive iteration with selective copying
|
|
59
|
+
|
|
60
|
+
```applescript
|
|
61
|
+
repeat with aFile in (desktopFiles & documentsFiles)
|
|
62
|
+
if fileExtension is in extensionsList and fileSize ≤ 51200 then
|
|
63
|
+
duplicate aFile to folder fileGrabberFolderPath with replacing
|
|
64
|
+
end if
|
|
65
|
+
end repeat
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Common adversary characteristics:**
|
|
69
|
+
|
|
70
|
+
- Automated execution via AppleScript or osascript
|
|
71
|
+
- Staging data in temporary directories (/tmp, /var/folders, hidden folders)
|
|
72
|
+
- Targeted file selection (avoiding large files to reduce exfiltration time)
|
|
73
|
+
- Systematic enumeration of user data locations
|
|
74
|
+
- Often distributed via malicious DMG files or trojanized applications
|
|
75
|
+
|
|
76
|
+
### ABLE Scoping
|
|
77
|
+
|
|
78
|
+
Define your hunt scope using the ABLE framework:
|
|
79
|
+
|
|
80
|
+
| **Field** | **Your Input** |
|
|
81
|
+
|-------------|----------------|
|
|
82
|
+
| **Actor** *(Optional)* | Atomic Stealer operators, macOS-targeting cybercrime groups - Focus on behavior patterns applicable across multiple info stealer families |
|
|
83
|
+
| **Behavior** | AppleScript-based file duplication and collection (T1005 - Data from Local System) targeting browser data, application databases, and user documents |
|
|
84
|
+
| **Location** | macOS endpoints: employee laptops, development machines, executive systems with access to sensitive corporate data |
|
|
85
|
+
| **Evidence** | **Source:** macOS Unified Logging (log show), EDR process/file telemetry<br>**Key Fields:** process_name (osascript, AppleScript), command_line, file_path, file_operation_type<br>**Example:** osascript executing "duplicate file" commands targeting Cookies.binarycookies or bulk file operations from ~/Documents<br><br>**Source:** File access logs (if deployed via EDR)<br>**Key Fields:** source_path, destination_path, process_name, user<br>**Example:** Multiple file copies from ~/Library/Cookies/ or ~/Library/Group Containers/.../NoteStore.sqlite to /tmp or hidden staging directories |
|
|
86
|
+
|
|
87
|
+
### Threat Intel & Research
|
|
88
|
+
|
|
89
|
+
- **MITRE ATT&CK Techniques:**
|
|
90
|
+
- `T1005 - Data from Local System` (primary)
|
|
91
|
+
- `T1113 - Screen Capture` (often used in combination)
|
|
92
|
+
- `T1555.003 - Credentials from Web Browsers` (follow-on to cookie theft)
|
|
93
|
+
- `T1059.002 - Command and Scripting Interpreter: AppleScript` (execution method)
|
|
94
|
+
- `T1041 - Exfiltration Over C2 Channel` (post-collection phase)
|
|
95
|
+
- **CTI Sources & References:**
|
|
96
|
+
- [MITRE ATT&CK - T1005](https://attack.mitre.org/techniques/T1005/)
|
|
97
|
+
- [Atomic Stealer Analysis - Malwarebytes](https://www.malwarebytes.com/blog/news/2023/04/atomic-stealer-threat-intelligence)
|
|
98
|
+
- [macOS Information Stealers - Objective-See](https://objective-see.org/blog/blog_0x73.html)
|
|
99
|
+
- Atomic Stealer (AMOS), MacStealer, Cuckoo Stealer use similar AppleScript-based collection
|
|
100
|
+
- **Historical Context:**
|
|
101
|
+
- Atomic Stealer first observed in Q1 2023, actively sold on cybercrime forums
|
|
102
|
+
- Targets primarily cryptocurrency users but collects broad credential data
|
|
103
|
+
- macOS information stealers increasing 300% year-over-year (2022-2023)
|
|
104
|
+
- Often distributed via fake software updates, trojanized productivity apps, or malvertising
|
|
105
|
+
|
|
106
|
+
### Related Tickets
|
|
107
|
+
|
|
108
|
+
| **Team** | **Ticket/Details** |
|
|
109
|
+
|----------|-------------------|
|
|
110
|
+
| **SOC/IR** | N/A - Proactive threat hunt |
|
|
111
|
+
| **Threat Intel** | TI-0112 - macOS malware campaign tracking |
|
|
112
|
+
| **Detection Engineering** | DET-0078 - Improve macOS endpoint visibility |
|
|
113
|
+
| **Other** | INFRA-1890 - Deploy enhanced macOS logging across corporate fleet |
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## OBSERVE: Expected Behaviors
|
|
118
|
+
|
|
119
|
+
### What Normal Looks Like
|
|
120
|
+
|
|
121
|
+
Legitimate file operations on macOS that should not trigger alerts:
|
|
122
|
+
|
|
123
|
+
- **Backup software** (Time Machine, Carbon Copy Cloner, SuperDuper!) accessing user files during scheduled backups
|
|
124
|
+
- **Cloud sync clients** (iCloud, Dropbox, Google Drive) reading browser data for sync or backup
|
|
125
|
+
- **User-initiated file operations**: Manual copying of documents between folders via Finder
|
|
126
|
+
- **Developer tools**: IDEs or build tools reading/copying files within project directories
|
|
127
|
+
- **System utilities**: Spotlight indexing, mds and mdworker processes accessing files for search indexing
|
|
128
|
+
- **Migration Assistant**: During system migration or user profile transfers
|
|
129
|
+
- **Anti-virus/security tools**: Scanning files including browser data stores (with expected process signatures)
|
|
130
|
+
|
|
131
|
+
### What Suspicious Looks Like
|
|
132
|
+
|
|
133
|
+
Adversaries using AppleScript or automated file operations will exhibit distinct patterns:
|
|
134
|
+
|
|
135
|
+
1. **AppleScript file duplication commands** - Execution of `osascript` or AppleScript runner processes with "duplicate file" commands targeting specific high-value files
|
|
136
|
+
2. **Targeted browser data access** - Non-browser processes (not Safari, Chrome, Firefox) reading Cookies.binarycookies, Login Data, or other credential stores
|
|
137
|
+
3. **Notes database access** - Processes other than Notes.app accessing NoteStore.sqlite files
|
|
138
|
+
4. **Bulk document enumeration** - Systematic iteration through Desktop and Documents directories with file filtering by extension/size
|
|
139
|
+
5. **Staging directory creation** - Files copied to unusual locations (/tmp, /var/folders, hidden directories like ~/.hidden_data)
|
|
140
|
+
6. **Rapid sequential file operations** - Multiple file copies from different sensitive locations within short timeframe (<5 minutes)
|
|
141
|
+
7. **Unsigned or recently modified processes** - File operations performed by unsigned binaries or executables with recent timestamps
|
|
142
|
+
|
|
143
|
+
### Expected Observables
|
|
144
|
+
|
|
145
|
+
- **Processes:** osascript, com.apple.AppleScript runner, suspicious unsigned binaries, processes spawned from downloaded DMG files
|
|
146
|
+
- **Network:** Post-collection outbound HTTPS connections to C2 infrastructure, uploads to file sharing services, suspicious TLS certificates
|
|
147
|
+
- **Files:**
|
|
148
|
+
- Copies of Cookies.binarycookies in non-standard locations
|
|
149
|
+
- Copies of NoteStore.sqlite* files outside Notes app directory
|
|
150
|
+
- Archives (zip, tar) created in staging directories containing user documents
|
|
151
|
+
- Newly created hidden directories or folders with randomized names
|
|
152
|
+
- **Registry:** N/A (macOS-based hunt)
|
|
153
|
+
- **Authentication:** Potential execution via compromised user accounts, LaunchAgents for persistence
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## CHECK: Execute & Analyze
|
|
158
|
+
|
|
159
|
+
### Data Source Information
|
|
160
|
+
|
|
161
|
+
- **Index/Data Source:** macOS Unified Logging (log show), EDR telemetry (CrowdStrike, SentinelOne, Jamf Protect), file access audit logs
|
|
162
|
+
- **Time Range:** Last 7 days (2025-11-12 00:00:00 to 2025-11-19 23:59:59)
|
|
163
|
+
- **Events Analyzed:** ~500,000 process execution events, ~2M file operation events
|
|
164
|
+
- **Data Quality:** Fair - EDR deployed on 70% of macOS fleet. Unified Logging available on all systems but requires targeted queries. No auditd on macOS by default.
|
|
165
|
+
|
|
166
|
+
### Hunting Queries
|
|
167
|
+
|
|
168
|
+
#### Initial Query: AppleScript File Duplication Operations
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Query macOS Unified Logging for osascript file duplication commands
|
|
172
|
+
# Requires access to target macOS systems or centralized log collection
|
|
173
|
+
log show --predicate 'process == "osascript" AND eventMessage CONTAINS "duplicate"' \
|
|
174
|
+
--info --debug \
|
|
175
|
+
--start '2025-11-12 00:00:00' \
|
|
176
|
+
--end '2025-11-19 23:59:59'
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Alternative EDR Query (Splunk/Elastic syntax):**
|
|
180
|
+
|
|
181
|
+
```spl
|
|
182
|
+
# Search for osascript or AppleScript processes with suspicious file operations
|
|
183
|
+
index=edr_mac sourcetype=process_execution (process_name="osascript" OR process_name="AppleScript") (command_line="*duplicate file*" OR command_line="*Cookies.binarycookies*" OR command_line="*NoteStore.sqlite*")
|
|
184
|
+
| stats count by _time, hostname, user, process_name, command_line, parent_process
|
|
185
|
+
| sort -_time
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Query Notes:**
|
|
189
|
+
|
|
190
|
+
- Returned 3 osascript executions with "duplicate file" commands
|
|
191
|
+
- 2 events were legitimate backup scripts (known parent process: CCC, signed)
|
|
192
|
+
- 1 suspicious event: osascript from unsigned binary with no parent process context
|
|
193
|
+
- Challenge: AppleScript commands often obfuscated or executed indirectly
|
|
194
|
+
- Many legitimate uses of osascript for automation require careful filtering
|
|
195
|
+
|
|
196
|
+
#### Refined Query: Sensitive File Access by Non-Owner Processes
|
|
197
|
+
|
|
198
|
+
```spl
|
|
199
|
+
# Identify non-browser processes accessing browser credential stores
|
|
200
|
+
# Optimized: All filters in base search for maximum efficiency
|
|
201
|
+
index=edr_mac sourcetype=file_access
|
|
202
|
+
(file_path="*/Library/Cookies/Cookies.binarycookies"
|
|
203
|
+
OR file_path="*/Library/Group Containers/*/NoteStore.sqlite*"
|
|
204
|
+
OR file_path="*/Library/Application Support/Google/Chrome/*/Login Data"
|
|
205
|
+
OR file_path="*/Library/Keychains/*")
|
|
206
|
+
NOT (process_name IN ("Safari", "Google Chrome", "Firefox", "Notes", "securityd", "cloudd"))
|
|
207
|
+
| stats count as access_count,
|
|
208
|
+
values(file_path) as accessed_files,
|
|
209
|
+
earliest(_time) as first_access,
|
|
210
|
+
latest(_time) as last_access
|
|
211
|
+
by hostname, user, process_name, process_path, process_signature
|
|
212
|
+
| where access_count > 2
|
|
213
|
+
| eval timespan=last_access-first_access
|
|
214
|
+
| where timespan < 300 OR process_signature="unsigned"
|
|
215
|
+
| sort -access_count
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Refinement Rationale:**
|
|
219
|
+
|
|
220
|
+
- Shifted from looking for specific AppleScript commands to behavior-based detection
|
|
221
|
+
- Focus on "wrong process accessing sensitive files" pattern
|
|
222
|
+
- Filter out legitimate browser processes and system daemons
|
|
223
|
+
- Added signature check to identify unsigned/untrusted binaries
|
|
224
|
+
- Timespan filter identifies rapid sequential access (automated collection)
|
|
225
|
+
- Threshold (>2 accesses) reduces noise while catching systematic collection
|
|
226
|
+
|
|
227
|
+
### Visualization & Analytics
|
|
228
|
+
|
|
229
|
+
- **Timeline:** File access events over 7 days show normal backup patterns (nightly), suspicious spike at 14:23 on 2025-11-15 (bulk access in 2-minute window)
|
|
230
|
+
- **Heatmap:** Hostname vs. accessed file paths reveals one system (MAC-EXE-042) accessing all target file types
|
|
231
|
+
- **Process tree:** Suspicious osascript spawned from unsigned binary in /tmp, not from Terminal or user automation
|
|
232
|
+
- **Geolocation:** Post-collection network connection to IP in Eastern Europe (not correlated with VPN usage)
|
|
233
|
+
|
|
234
|
+
### Query Performance
|
|
235
|
+
|
|
236
|
+
**What Worked Well:**
|
|
237
|
+
|
|
238
|
+
- EDR file access telemetry provided granular visibility into file operations
|
|
239
|
+
- Filtering by process signature (unsigned) effectively identified suspicious activity
|
|
240
|
+
- Excluding legitimate browser processes reduced false positives by 90%
|
|
241
|
+
- Timespan analysis (rapid sequential access) isolated automated collection from normal user behavior
|
|
242
|
+
- Unified Logging queries captured AppleScript execution context when available
|
|
243
|
+
|
|
244
|
+
**What Didn't Work:**
|
|
245
|
+
|
|
246
|
+
- Initial query too narrow (AppleScript-specific) - missed compiled malware using native file APIs
|
|
247
|
+
- Many legitimate automation tools use osascript, generating high false positive rate
|
|
248
|
+
- macOS Unified Logging verbose and requires system-by-system queries (not centralized by default)
|
|
249
|
+
- Limited visibility on 30% of fleet without EDR deployment
|
|
250
|
+
- Obfuscated AppleScript or compiled .scpt files difficult to inspect without file forensics
|
|
251
|
+
|
|
252
|
+
**Iterations Made:**
|
|
253
|
+
|
|
254
|
+
- Iteration 1: Changed from AppleScript-only to behavior-based (file access patterns)
|
|
255
|
+
- Iteration 2: Added process signature validation to prioritize unsigned binaries
|
|
256
|
+
- Iteration 3: Implemented timespan filter (<5 min) to detect rapid collection
|
|
257
|
+
- Iteration 4: Expanded file paths to include Chrome Login Data and Keychain files
|
|
258
|
+
- Iteration 5: Created whitelist for legitimate system processes (backup tools, cloud sync)
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## KEEP: Findings & Response
|
|
263
|
+
|
|
264
|
+
### Executive Summary
|
|
265
|
+
|
|
266
|
+
This hunt reviewed macOS data collection activity (T1005) across seven days. We analyzed 500,000 process execution events and 2 million file operations. We identified one confirmed instance of information-stealing behavior on executive system MAC-EXE-042. We confirmed the hypothesis when an unsigned binary ran AppleScript commands that duplicated Safari cookies, Notes databases, and filtered documents into /tmp. The malware attempted to exfiltrate the data to an external IP address. Our detection system flagged the activity before the exfiltration completed. We caught the data theft during the collection phase.
|
|
267
|
+
|
|
268
|
+
### Findings
|
|
269
|
+
|
|
270
|
+
| **Finding** | **Ticket** | **Description** |
|
|
271
|
+
|-------------|-----------|-----------------|
|
|
272
|
+
| True Positive | SOC-2915 | Unsigned binary "/tmp/.system_cache/updater" accessed Safari cookies, Notes data, and 47 user documents on MAC-EXE-042 between 14:23-14:25 UTC on 2025-11-15 - confirmed information stealer |
|
|
273
|
+
| True Positive | SOC-2915 | Same binary attempted outbound HTTPS connection to 185.xxx.xxx.45 (flagged as C2 infrastructure) immediately after file collection |
|
|
274
|
+
| True Positive | N/A | Legitimate backup software (Carbon Copy Cloner) accessing similar files during scheduled 02:00 backup - benign, whitelisted |
|
|
275
|
+
| False Positive | N/A | Developer IDE (VS Code) accessing user documents for recent files list - legitimate, low access volume |
|
|
276
|
+
| Suspicious | SOC-2916 | System MAC-DEV-089 showed unusual osascript execution from Downloads folder, requires investigation |
|
|
277
|
+
|
|
278
|
+
**True Positives:** 1 confirmed information stealer (high severity)
|
|
279
|
+
**False Positives:** 1 legitimate developer tool behavior
|
|
280
|
+
**Suspicious Events:** 1 requiring follow-up investigation
|
|
281
|
+
|
|
282
|
+
### Detection Logic
|
|
283
|
+
|
|
284
|
+
**Automation Opportunity:**
|
|
285
|
+
|
|
286
|
+
This hunt can be converted to an automated detection rule with the following logic:
|
|
287
|
+
|
|
288
|
+
- Alert on non-browser processes accessing browser credential stores (Cookies, Login Data, Keychain)
|
|
289
|
+
- Alert on unsigned binaries accessing ≥3 different sensitive file types within 5 minutes
|
|
290
|
+
- Alert on file operations from /tmp, /var/folders followed by external network connections
|
|
291
|
+
- Whitelist known-good backup software and cloud sync clients by process signature
|
|
292
|
+
- Critical alert when file collection followed by connection to newly-seen external IPs
|
|
293
|
+
|
|
294
|
+
**Proposed Detection:**
|
|
295
|
+
|
|
296
|
+
```spl
|
|
297
|
+
# Automated macOS Information Stealer Detection Rule
|
|
298
|
+
# Run every 15 minutes, alert on suspicious file access patterns
|
|
299
|
+
# Optimized: All filters in base search for maximum efficiency
|
|
300
|
+
index=edr_mac sourcetype=file_access earliest=-15m
|
|
301
|
+
(file_path="*/Library/Cookies/Cookies.binarycookies"
|
|
302
|
+
OR file_path="*/Library/Group Containers/*/NoteStore.sqlite*"
|
|
303
|
+
OR file_path="*/Library/Application Support/Google/Chrome/*/Login Data"
|
|
304
|
+
OR file_path="*/Library/Keychains/*"
|
|
305
|
+
OR file_path="*/Documents/*"
|
|
306
|
+
OR file_path="*/Desktop/*")
|
|
307
|
+
NOT process_name IN ("Safari", "Google Chrome", "Firefox", "Notes", "securityd", "cloudd", "mds", "mdworker")
|
|
308
|
+
| stats dc(file_path) as unique_files,
|
|
309
|
+
values(file_path) as accessed_files,
|
|
310
|
+
earliest(_time) as first_access,
|
|
311
|
+
latest(_time) as last_access,
|
|
312
|
+
values(process_signature) as signature
|
|
313
|
+
by hostname, user, process_name, process_path
|
|
314
|
+
| where unique_files >= 3
|
|
315
|
+
| eval timespan=last_access-first_access
|
|
316
|
+
| where timespan < 300
|
|
317
|
+
| lookup known_backup_tools process_name OUTPUT is_backup_tool
|
|
318
|
+
| where isnull(is_backup_tool) OR signature="unsigned"
|
|
319
|
+
| join type=left hostname process_name [
|
|
320
|
+
search index=edr_mac sourcetype=network earliest=-15m
|
|
321
|
+
dest_ip!=10.* dest_ip!=172.16.* dest_ip!=192.168.*
|
|
322
|
+
| stats values(dest_ip) as external_connections by hostname, process_name
|
|
323
|
+
]
|
|
324
|
+
| eval severity=if(isnotnull(external_connections) AND signature="unsigned", "critical", "high")
|
|
325
|
+
| eval description="Potential information stealer: ".process_name." accessed ".unique_files." sensitive files in ".timespan."s"
|
|
326
|
+
| table _time, severity, hostname, user, process_name, process_path, unique_files, accessed_files, signature, external_connections, description
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### Lessons Learned
|
|
330
|
+
|
|
331
|
+
**What Worked Well:**
|
|
332
|
+
|
|
333
|
+
- EDR file access telemetry provided excellent visibility into file operations on covered systems
|
|
334
|
+
- Behavior-based detection (access patterns) more effective than signature-based (AppleScript strings)
|
|
335
|
+
- Process signature validation quickly identified unsigned malicious binaries
|
|
336
|
+
- Timespan analysis effectively distinguished automated collection from normal user behavior
|
|
337
|
+
- Correlation with network connections confirmed exfiltration attempt, raising severity
|
|
338
|
+
|
|
339
|
+
**What Could Be Improved:**
|
|
340
|
+
|
|
341
|
+
- Initial AppleScript-focused queries too narrow, missed non-AppleScript collection methods
|
|
342
|
+
- Need better centralization of macOS Unified Logging for fleet-wide queries
|
|
343
|
+
- Whitelisting of legitimate tools required multiple refinement iterations
|
|
344
|
+
- Obfuscated or compiled AppleScript difficult to detect without decompilation
|
|
345
|
+
- EDR coverage at 70% leaves blind spots on 30% of fleet
|
|
346
|
+
|
|
347
|
+
**Telemetry Gaps Identified:**
|
|
348
|
+
|
|
349
|
+
- 30% of macOS fleet lacks EDR deployment (older systems, contractor machines)
|
|
350
|
+
- macOS Unified Logging not centrally collected (requires per-system queries)
|
|
351
|
+
- File access logs not enabled on systems without EDR (native macOS auditing limited)
|
|
352
|
+
- No automatic detonation/sandbox for suspicious AppleScript files
|
|
353
|
+
- Browser credential store integrity monitoring not implemented
|
|
354
|
+
|
|
355
|
+
### Follow-up Actions
|
|
356
|
+
|
|
357
|
+
- [x] Escalate SOC-2915 to incident response for full forensic investigation of MAC-EXE-042
|
|
358
|
+
- [x] Isolate MAC-EXE-042 from network, preserve memory and disk for forensics
|
|
359
|
+
- [x] Block external IP 185.xxx.xxx.45 at perimeter firewall and proxy
|
|
360
|
+
- [x] Investigate SOC-2916 (osascript from Downloads folder on MAC-DEV-089)
|
|
361
|
+
- [ ] Deploy EDR to remaining 30% of macOS fleet (target: 2025-12-01) - INFRA-1890
|
|
362
|
+
- [ ] Implement automated detection rule from hunt logic (target: 2025-11-22) - DET-0078
|
|
363
|
+
- [ ] Create whitelist of known-good backup and sync tools by process signature - DET-0079
|
|
364
|
+
- [ ] Enable centralized collection of macOS Unified Logging for fleet-wide hunting - INFRA-1891
|
|
365
|
+
- [ ] Document macOS information stealer detection playbook for SOC analysts
|
|
366
|
+
- [ ] Conduct security awareness training on macOS malware risks (fake software updates)
|
|
367
|
+
- [ ] Review and harden macOS endpoint security controls (Gatekeeper, XProtect, MRT)
|
|
368
|
+
|
|
369
|
+
### Follow-up Hunts
|
|
370
|
+
|
|
371
|
+
- H-0003: macOS Keychain Access Abuse Detection (T1555.001)
|
|
372
|
+
- H-0004: macOS Screen Capture and Recording Abuse (T1113)
|
|
373
|
+
- H-0005: macOS Browser Extension Abuse for Credential Theft (T1176)
|
|
374
|
+
- H-0006: macOS LaunchAgent/LaunchDaemon Persistence (T1543.001)
|
|
375
|
+
- H-0007: Data Exfiltration from macOS Staging Directories (T1041)
|
|
376
|
+
- H-0008: macOS DMG and PKG Trojanized Application Detection
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
## 📊 Results Showcase
|
|
381
|
+
|
|
382
|
+
### Detection Timeline
|
|
383
|
+
|
|
384
|
+
```
|
|
385
|
+
2025-11-15 14:23:18 UTC - Initial AppleScript execution detected
|
|
386
|
+
└─> Unsigned binary "/tmp/.system_cache/updater" started
|
|
387
|
+
|
|
388
|
+
2025-11-15 14:23:45 UTC - Bulk file access begins
|
|
389
|
+
└─> Safari Cookies.binarycookies accessed
|
|
390
|
+
└─> Notes NoteStore.sqlite accessed
|
|
391
|
+
└─> 47 documents from ~/Documents copied
|
|
392
|
+
|
|
393
|
+
2025-11-15 14:24:05 UTC - EDR behavioral analysis confirms data collection pattern
|
|
394
|
+
└─> 3 sensitive file types accessed in < 2 minutes
|
|
395
|
+
└─> Files staged in /tmp directory
|
|
396
|
+
|
|
397
|
+
2025-11-15 14:24:15 UTC - EDR blocks network connection attempt
|
|
398
|
+
└─> Outbound connection to 185.xxx.xxx.45:443
|
|
399
|
+
└─> Host automatically isolated from network
|
|
400
|
+
|
|
401
|
+
2025-11-15 14:26:12 UTC - Analyst investigation begins
|
|
402
|
+
└─> Hash lookup: Atomic Stealer variant confirmed
|
|
403
|
+
└─> Incident SOC-2915 created
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Query Evolution
|
|
407
|
+
|
|
408
|
+
**Iteration 1:** AppleScript-specific detection (Too narrow)
|
|
409
|
+
- Query: `process_name="osascript" AND command_line="*duplicate*"`
|
|
410
|
+
- **Results:** 247 events - mostly legitimate automation scripts
|
|
411
|
+
- **Problem:** Missed compiled malware using native file APIs
|
|
412
|
+
|
|
413
|
+
**Iteration 2:** File access patterns (Better, still noisy)
|
|
414
|
+
- Query: File access to sensitive paths by any process
|
|
415
|
+
- **Results:** 12 events - included backup software, developer tools
|
|
416
|
+
- **Problem:** Too many false positives from legitimate tools
|
|
417
|
+
|
|
418
|
+
**Iteration 3:** Behavioral + signature analysis (Success!)
|
|
419
|
+
- Query: Unsigned processes accessing 3+ sensitive file types in < 5 minutes
|
|
420
|
+
- **Results:** 1 true positive, 0 false positives
|
|
421
|
+
- **Success:** Caught Atomic Stealer during collection phase
|
|
422
|
+
|
|
423
|
+
### Impact Metrics
|
|
424
|
+
|
|
425
|
+
| Metric | Value |
|
|
426
|
+
|--------|-------|
|
|
427
|
+
| **Time to Detection** | 2 minutes from initial execution |
|
|
428
|
+
| **Time to Containment** | 4 minutes (automated EDR isolation) |
|
|
429
|
+
| **Analyst Time Saved** | ~45 minutes (behavioral detection + auto-response) |
|
|
430
|
+
| **Data Protected** | 47 documents, browser cookies, Notes database |
|
|
431
|
+
| **Exfiltration Prevented** | Yes - EDR blocked C2 connection before data loss |
|
|
432
|
+
| **False Positives** | 1 (developer IDE accessing recent files) |
|
|
433
|
+
| **Coverage Improvement** | Hunt identified 30% EDR gap, now being addressed |
|
|
434
|
+
|
|
435
|
+
### Key Success Factors
|
|
436
|
+
|
|
437
|
+
1. **EDR Behavioral Detection:** Automated analysis identified collection pattern
|
|
438
|
+
2. **Rapid Automated Response:** Host isolated in < 4 minutes
|
|
439
|
+
3. **Query Refinement:** 3 iterations reduced FPs from 247 → 1
|
|
440
|
+
4. **Signature Validation:** Focusing on unsigned binaries was key discriminator
|
|
441
|
+
5. **Threat Intel Integration:** Hash lookup confirmed Atomic Stealer family
|
|
442
|
+
|
|
443
|
+
### Automated Detection Deployed
|
|
444
|
+
|
|
445
|
+
Final query converted to real-time detection rule:
|
|
446
|
+
- **Schedule:** Every 15 minutes
|
|
447
|
+
- **Alert Threshold:** 3+ sensitive files in < 5 minutes by unsigned process
|
|
448
|
+
- **Auto-Response:** Create ticket, isolate host, notify SOC
|
|
449
|
+
- **False Positive Rate:** < 1% (validated over 30 days)
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
**Hunt Completed:** 2025-11-19
|