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.
Files changed (43) hide show
  1. {agentic_threat_hunting_framework-0.2.3.dist-info → agentic_threat_hunting_framework-0.3.0.dist-info}/METADATA +38 -40
  2. agentic_threat_hunting_framework-0.3.0.dist-info/RECORD +51 -0
  3. athf/__version__.py +1 -1
  4. athf/cli.py +7 -2
  5. athf/commands/__init__.py +4 -0
  6. athf/commands/agent.py +452 -0
  7. athf/commands/context.py +6 -9
  8. athf/commands/env.py +2 -2
  9. athf/commands/hunt.py +3 -3
  10. athf/commands/init.py +45 -0
  11. athf/commands/research.py +530 -0
  12. athf/commands/similar.py +5 -5
  13. athf/core/research_manager.py +419 -0
  14. athf/core/web_search.py +340 -0
  15. athf/data/__init__.py +19 -0
  16. athf/data/docs/CHANGELOG.md +147 -0
  17. athf/data/docs/CLI_REFERENCE.md +1797 -0
  18. athf/data/docs/INSTALL.md +594 -0
  19. athf/data/docs/README.md +31 -0
  20. athf/data/docs/environment.md +256 -0
  21. athf/data/docs/getting-started.md +419 -0
  22. athf/data/docs/level4-agentic-workflows.md +480 -0
  23. athf/data/docs/lock-pattern.md +149 -0
  24. athf/data/docs/maturity-model.md +400 -0
  25. athf/data/docs/why-athf.md +44 -0
  26. athf/data/hunts/FORMAT_GUIDELINES.md +507 -0
  27. athf/data/hunts/H-0001.md +453 -0
  28. athf/data/hunts/H-0002.md +436 -0
  29. athf/data/hunts/H-0003.md +546 -0
  30. athf/data/hunts/README.md +231 -0
  31. athf/data/integrations/MCP_CATALOG.md +45 -0
  32. athf/data/integrations/README.md +129 -0
  33. athf/data/integrations/quickstart/splunk.md +162 -0
  34. athf/data/knowledge/hunting-knowledge.md +2375 -0
  35. athf/data/prompts/README.md +172 -0
  36. athf/data/prompts/ai-workflow.md +581 -0
  37. athf/data/prompts/basic-prompts.md +316 -0
  38. athf/data/templates/HUNT_LOCK.md +228 -0
  39. agentic_threat_hunting_framework-0.2.3.dist-info/RECORD +0 -23
  40. {agentic_threat_hunting_framework-0.2.3.dist-info → agentic_threat_hunting_framework-0.3.0.dist-info}/WHEEL +0 -0
  41. {agentic_threat_hunting_framework-0.2.3.dist-info → agentic_threat_hunting_framework-0.3.0.dist-info}/entry_points.txt +0 -0
  42. {agentic_threat_hunting_framework-0.2.3.dist-info → agentic_threat_hunting_framework-0.3.0.dist-info}/licenses/LICENSE +0 -0
  43. {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,436 @@
1
+ ---
2
+ hunt_id: H-0002
3
+ title: Linux Crontab Persistence Detection
4
+ status: completed
5
+ date: 2025-11-19
6
+ hunter: [Your Name]
7
+ platform: [Linux]
8
+ tactics: [persistence]
9
+ techniques: [T1053.003, T1059.004, T1071.001, T1027]
10
+ data_sources: [Auditd, Syslog, Linux Secure Logs]
11
+ related_hunts: []
12
+ findings_count: 3
13
+ true_positives: 1
14
+ false_positives: 1
15
+ customer_deliverables: []
16
+ tags: [linux, cron, persistence, scheduled-tasks, cryptomining]
17
+ ---
18
+
19
+ # H-0002: Linux Crontab Persistence Detection
20
+
21
+ **Hunt Metadata**
22
+
23
+ - **Date:** 2025-11-19
24
+ - **Hunter:** [Your Name]
25
+ - **Status:** Completed
26
+ - **MITRE ATT&CK:** T1053.003 - Scheduled Task/Job: Cron
27
+
28
+ ---
29
+
30
+ ## LEARN: Prepare the Hunt
31
+
32
+ ### Hypothesis Statement
33
+
34
+ Detect adversary persistence via malicious cron job creation or modification (T1053.003) on Linux systems by identifying suspicious crontab entries, file modifications outside maintenance windows, and execution of unusual commands from cron processes.
35
+
36
+ ### Threat Context
37
+
38
+ Adversaries may abuse cron on Linux systems to establish persistence by scheduling malicious commands or scripts to execute at system startup or on a defined schedule. Cron jobs are commonly used by threat actors to maintain access, execute payloads, or perform reconnaissance activities. This technique allows attackers to survive system reboots and maintain long-term access to compromised hosts.
39
+
40
+ Key persistence locations:
41
+
42
+ - User crontabs: `/var/spool/cron/crontabs/*`
43
+ - System-wide: `/etc/crontab`, `/etc/cron.d/*`
44
+ - Scheduled directories: `/etc/cron.hourly/`, `/etc/cron.daily/`, `/etc/cron.weekly/`, `/etc/cron.monthly/`
45
+
46
+ Common adversary patterns:
47
+
48
+ - Unusual timing patterns (every minute, odd schedules)
49
+ - Commands with network activity (curl, wget, nc)
50
+ - Obfuscated or base64-encoded commands
51
+ - Execution from temporary directories (/tmp, /dev/shm)
52
+ - Reverse shells or callback mechanisms
53
+ - Crontab modifications by non-administrative users
54
+
55
+ ### ABLE Scoping
56
+
57
+ Define your hunt scope using the ABLE framework:
58
+
59
+ | **Field** | **Your Input** |
60
+ |-------------|----------------|
61
+ | **Actor** *(Optional)* | N/A - Focus on persistence behavior patterns |
62
+ | **Behavior** | Malicious cron job creation/modification for persistence (T1053.003 - Scheduled Task/Job: Cron) |
63
+ | **Location** | All Linux servers (production web servers, database servers, application servers) |
64
+ | **Evidence** | **Source:** Auditd file integrity monitoring<br>**Key Fields:** file_path, action (modified/created), user, process_name, timestamp<br>**Example:** Non-root user modifying /var/spool/cron/crontabs/* with curl/wget commands<br><br>**Source:** Syslog / Linux Secure logs<br>**Key Fields:** parent_process, command_line, user, cron_schedule<br>**Example:** Cron daemon spawning bash with suspicious network commands |
65
+
66
+ ### Threat Intel & Research
67
+
68
+ - **MITRE ATT&CK Techniques:**
69
+ - `T1053.003 - Scheduled Task/Job: Cron`
70
+ - `T1059.004 - Command and Scripting Interpreter: Unix Shell` (often used together)
71
+ - `T1071.001 - Application Layer Protocol: Web Protocols` (curl/wget for C2)
72
+ - `T1027 - Obfuscated Files or Information` (base64-encoded cron commands)
73
+ - **CTI Sources & References:**
74
+ - [MITRE ATT&CK - T1053.003](https://attack.mitre.org/techniques/T1053/003/)
75
+ - Common in Linux post-exploitation frameworks (Metasploit, Empire, Cobalt Strike)
76
+ - APT groups using cron persistence: APT28, Rocke (cryptomining), TeamTNT (cloud)
77
+ - **Historical Context:**
78
+ - Previous incident (2024-Q3): Cryptomining malware used cron for persistence on dev servers
79
+ - Current baseline: ~200 legitimate cron jobs across production environment
80
+ - Known false positives: Certbot, log rotation, backup scripts, package managers
81
+
82
+ ### Related Tickets
83
+
84
+ | **Team** | **Ticket/Details** |
85
+ |----------|-------------------|
86
+ | **SOC/IR** | N/A |
87
+ | **Threat Intel** | TI-0089 - Cryptomining campaign targeting cloud infrastructure |
88
+ | **Detection Engineering** | DET-0051 - Implement file integrity monitoring for cron directories |
89
+ | **Other** | INFRA-1456 - Baseline legitimate cron jobs per host type |
90
+
91
+ ---
92
+
93
+ ## OBSERVE: Expected Behaviors
94
+
95
+ ### What Normal Looks Like
96
+
97
+ Legitimate cron activity that should not trigger alerts:
98
+
99
+ - System package managers scheduling updates (apt, yum, dnf) in /etc/cron.daily/
100
+ - Certificate renewal tools (certbot, acme.sh) running in /etc/cron.d/
101
+ - Log rotation via logrotate in /etc/cron.daily/
102
+ - Backup scripts scheduled by root user during maintenance windows (typically 02:00-04:00 UTC)
103
+ - Monitoring agents (Datadog, New Relic) running health checks
104
+ - Database maintenance jobs (vacuum, analyze) scheduled by database users
105
+ - Application-specific tasks managed by service accounts with documented purposes
106
+
107
+ ### What Suspicious Looks Like
108
+
109
+ Adversaries will modify crontab files to achieve persistence on Linux hosts. We expect to see:
110
+
111
+ 1. **File modifications** to crontab-related files outside normal maintenance windows
112
+ 2. **Suspicious commands** in cron entries containing:
113
+ - Network utilities: `curl`, `wget`, `nc`, `ncat`, `socat`
114
+ - Shell invocations: `bash -c`, `sh -c`, `/dev/tcp/`
115
+ - Encoding: `base64`, `echo`, piped to `sh` or `bash`
116
+ - Temporary paths: `/tmp`, `/dev/shm`, `/var/tmp`
117
+ 3. **Unusual crontab users** - modifications by non-root, non-admin accounts
118
+ 4. **Process execution** from cron daemon spawning unexpected commands
119
+ 5. **New cron files** created in `/etc/cron.d/` with suspicious ownership
120
+
121
+ ### Expected Observables
122
+
123
+ - **Processes:** Cron daemon spawning bash/sh with unusual command lines, network utilities (curl, wget, nc)
124
+ - **Network:** Outbound connections from cron-spawned processes to external IPs or unusual ports
125
+ - **Files:** Modifications to /etc/crontab, /var/spool/cron/crontabs/*, /etc/cron.d/*, /etc/cron.{hourly,daily,weekly,monthly}/
126
+ - **Registry:** N/A (Linux-based hunt)
127
+ - **Authentication:** Crontab command execution by non-administrative users, unusual process ownership
128
+
129
+ ---
130
+
131
+ ## CHECK: Execute & Analyze
132
+
133
+ ### Data Source Information
134
+
135
+ - **Index/Data Source:** index=linux, auditd logs, syslog, bash_history
136
+ - **Time Range:** Last 7 days (2025-11-12 00:00:00 to 2025-11-19 23:59:59)
137
+ - **Events Analyzed:** ~50,000 auditd events, ~30,000 syslog entries
138
+ - **Data Quality:** Fair - Auditd deployed on production servers (80% coverage), Dev environments lack FIM monitoring
139
+
140
+ ### Hunting Queries
141
+
142
+ #### Initial Query: File Integrity Monitoring for Crontab Changes
143
+
144
+ ```bash
145
+ # For hosts with auditd logging
146
+ # Optimized: All filters in base search for maximum efficiency
147
+ index=linux sourcetype=auditd
148
+ file_path IN ("/etc/crontab", "/etc/cron.d/*", "/var/spool/cron/crontabs/*", "/etc/cron.hourly/*", "/etc/cron.daily/*", "/etc/cron.weekly/*", "/etc/cron.monthly/*")
149
+ action IN ("modified", "created", "written")
150
+ | stats count by _time, host, user, file_path, action, process_name
151
+ | where user!="root" OR process_name!="crontab"
152
+ | sort -_time
153
+ ```
154
+
155
+ **Query Notes:**
156
+
157
+ - Returned 12 crontab modification events over 7-day period
158
+ - 3 events from root user during maintenance window (expected)
159
+ - 2 suspicious events from "webadmin" user modifying /var/spool/cron/crontabs/webadmin
160
+ - 7 events from certbot (legitimate certificate renewal)
161
+ - Most modifications occurred during business hours (09:00-17:00 UTC)
162
+
163
+ #### Refined Query: Suspicious Cron Command Patterns
164
+
165
+ ```bash
166
+ # For hosts collecting cron file contents
167
+ # Optimized: Filters in base search, pattern matching post-extraction
168
+ index=linux (sourcetype=linux_secure OR sourcetype=syslog)
169
+ ("CRON" OR "crontab")
170
+ | rex field=_raw "(?<cron_command>\*.*\s+.+)"
171
+ | search cron_command IN ("*curl*", "*wget*", "*nc *", "*ncat*", "*socat*", "*bash -c*", "*sh -c*", "*base64*", "*/tmp/*", "*/dev/shm/*", "*python -c*", "*perl -e*", "*/dev/tcp/*")
172
+ | stats count by host, cron_command, user
173
+ | sort -count
174
+ ```
175
+
176
+ **Refinement Rationale:**
177
+
178
+ - Shifted from file modification detection to content-based analysis
179
+ - Added pattern matching for specific malicious command indicators (curl, wget, base64, etc.)
180
+ - Focused on network utilities and obfuscation techniques commonly used for C2
181
+ - Prioritized cron entries executing from temporary directories (/tmp, /dev/shm)
182
+ - This query identifies the actual malicious payload, not just file changes
183
+
184
+ ### Visualization & Analytics
185
+
186
+ - **Timeline:** Crontab modification events over 7 days show clustering during maintenance windows (expected)
187
+ - **Heatmap:** User vs. file_path shows "webadmin" user modifying personal crontab (requires investigation)
188
+ - **Process tree:** Cron daemon spawning unexpected bash processes with network commands
189
+ - **Command frequency:** 98% of cron commands are legitimate (certbot, logrotate, apt), 2% require investigation
190
+
191
+ ### Query Performance
192
+
193
+ **What Worked Well:**
194
+
195
+ - Auditd file integrity monitoring effectively captured crontab modifications with full context
196
+ - Pattern matching on suspicious command strings identified high-risk cron entries
197
+ - User-based filtering (user!="root") reduced noise from legitimate system maintenance
198
+ - Process execution monitoring provided visibility into actual cron command execution
199
+
200
+ **What Didn't Work:**
201
+
202
+ - Initial query too broad - captured all crontab modifications including legitimate changes
203
+ - Regex extraction of cron_command field unreliable due to varied log formats
204
+ - Query 3 (process execution) generated false positives from legitimate system processes
205
+ - No baseline of "known good" cron jobs to compare against
206
+ - Bash history logging not consistently enabled across all servers (telemetry gap)
207
+
208
+ **Iterations Made:**
209
+
210
+ - Iteration 1: Added user filter to exclude root user modifications (reduced results by 70%)
211
+ - Iteration 2: Created separate query for suspicious command patterns vs. file modifications
212
+ - Iteration 3: Whitelisted common legitimate processes (certbot, logrotate, apt, yum)
213
+ - Iteration 4: Adjusted time range from 24h to 7 days for better pattern visibility
214
+
215
+ ### Manual Validation Steps
216
+
217
+ ```bash
218
+ # On suspected hosts, check current crontabs
219
+ for user in $(cut -f1 -d: /etc/passwd); do
220
+ echo "=== Crontab for $user ==="
221
+ crontab -u $user -l 2>/dev/null
222
+ done
223
+
224
+ # Check system crontabs
225
+ cat /etc/crontab
226
+ ls -la /etc/cron.d/
227
+ ls -la /etc/cron.{hourly,daily,weekly,monthly}/
228
+
229
+ # Review recent modifications
230
+ find /etc/cron* /var/spool/cron -type f -mtime -7 -ls
231
+ find /etc/cron* /var/spool/cron -type f -exec grep -l "curl\|wget\|nc\|bash -c\|base64\|/tmp" {} \;
232
+ ```
233
+
234
+ ---
235
+
236
+ ## KEEP: Findings & Response
237
+
238
+ ### Executive Summary
239
+
240
+ This hunt investigated cron-based persistence mechanisms (T1053.003) on Linux systems over a 7-day period. Analysis of 50,000 auditd events and 30,000 syslog entries identified 12 crontab modification events. The hypothesis was partially confirmed: while most crontab activity was legitimate system maintenance, one suspicious case was detected requiring investigation. A non-administrative user "webadmin" modified their personal crontab with commands containing network utilities, indicating potential adversary persistence. No confirmed malicious cron jobs were found, but the suspicious activity warrants incident response follow-up. Overall, 98% of cron activity was benign (certbot, logrotate, package managers), with 2% requiring further investigation.
241
+
242
+ ### Findings
243
+
244
+ | **Finding** | **Ticket** | **Description** |
245
+ |-------------|-----------|-----------------|
246
+ | Suspicious | SOC-2901 | User "webadmin" modified /var/spool/cron/crontabs/webadmin with curl command to external IP - requires IR investigation |
247
+ | True Positive | N/A | Legitimate cron modifications by root during maintenance window (3 events, expected) |
248
+ | True Positive | N/A | Certbot automatic certificate renewal cron entries (7 events, benign) |
249
+ | False Positive | N/A | Database backup scripts using curl to upload to S3 (legitimate but flagged due to curl pattern) |
250
+
251
+ **True Positives:** 1 suspicious case requiring investigation
252
+ **False Positives:** 1 legitimate backup script using curl
253
+ **Suspicious Events:** 1 requiring immediate incident response investigation (webadmin user)
254
+
255
+ ### Detection Logic
256
+
257
+ **Automation Opportunity:**
258
+
259
+ This hunt can be automated with the following approach:
260
+
261
+ - Alert on crontab file modifications by non-root users
262
+ - Pattern match cron commands for suspicious indicators (curl, wget, nc, base64, /tmp)
263
+ - Baseline legitimate cron jobs per host type to reduce false positives
264
+ - Combine file modification detection with command content analysis
265
+ - Correlate cron activity with network connections from cron-spawned processes
266
+
267
+ **Proposed Detection:**
268
+
269
+ ```bash
270
+ # Automated Cron Persistence Detection Rule
271
+ # Run every 1 hour, alert on suspicious crontab modifications or commands
272
+ # Optimized: All filters in base search for maximum efficiency
273
+ index=linux sourcetype=auditd earliest=-1h
274
+ file_path IN ("/etc/crontab", "/etc/cron.d/*", "/var/spool/cron/crontabs/*")
275
+ action IN ("modified", "created", "written")
276
+ | join type=left host [
277
+ search index=linux (sourcetype=linux_secure OR sourcetype=syslog) earliest=-1h "CRON"
278
+ | rex field=_raw "(?<cron_command>.+)"
279
+ | eval is_suspicious=if(match(cron_command, "curl|wget|nc|ncat|socat|bash -c|sh -c|base64|/tmp|/dev/shm|python -c|perl -e|/dev/tcp"), "true", "false")
280
+ | stats values(cron_command) as commands, max(is_suspicious) as suspicious_command by host
281
+ ]
282
+ | where (user!="root" AND process_name!="certbot") OR suspicious_command="true"
283
+ | lookup cron_baseline host, user OUTPUT is_baseline
284
+ | where isnull(is_baseline) OR is_baseline="false"
285
+ | eval severity=if(suspicious_command="true", "high", "medium")
286
+ | eval description="Suspicious cron modification detected on ".host." by user ".user
287
+ | table _time, severity, host, user, file_path, action, process_name, commands, description
288
+ ```
289
+
290
+ ### Lessons Learned
291
+
292
+ **What Worked Well:**
293
+
294
+ - Auditd file integrity monitoring provided comprehensive visibility into crontab modifications
295
+ - Pattern matching on suspicious command strings effectively identified high-risk entries
296
+ - User-based filtering (excluding root) significantly reduced false positives
297
+ - Multi-query approach (file changes + command content + process execution) provided defense-in-depth
298
+ - Manual validation steps confirmed automated findings with 100% accuracy
299
+
300
+ **What Could Be Improved:**
301
+
302
+ - Baseline of "known good" cron jobs needed to reduce investigation time
303
+ - Cron command regex extraction unreliable due to inconsistent log formats
304
+ - Better integration between file modification alerts and command content analysis
305
+ - Whitelist management for legitimate tools using suspicious patterns (backup scripts with curl)
306
+ - Query performance optimization - 7-day queries took 15+ seconds on large datasets
307
+
308
+ **Telemetry Gaps Identified:**
309
+
310
+ - Dev/staging environments lack auditd monitoring (only 80% production coverage)
311
+ - Bash history logging inconsistently enabled (missing command-line context)
312
+ - No automated cron job inventory for baseline comparison
313
+ - Network connection logging not correlated with cron process execution
314
+ - Missing sysmon for Linux deployment (would provide richer process telemetry)
315
+
316
+ ### Follow-up Actions
317
+
318
+ - [x] Escalate SOC-2901 to incident response for webadmin user investigation
319
+ - [ ] Create baseline inventory of legitimate cron jobs per host type (target: 2025-11-25)
320
+ - [ ] Deploy auditd to dev/staging environments for complete coverage (INFRA-1457)
321
+ - [ ] Implement automated cron persistence detection rule (DET-0051)
322
+ - [ ] Enable bash history logging across all Linux servers (INFRA-1458)
323
+ - [ ] Create whitelist for known-good cron patterns (backup scripts, monitoring)
324
+ - [ ] Document cron persistence detection playbook for SOC analysts
325
+ - [ ] Schedule recurring hunt execution (monthly)
326
+
327
+ ### Follow-up Hunts
328
+
329
+ - H-0008: Systemd Timer Persistence Detection (T1053.006)
330
+ - H-0009: Linux Backdoor Analysis on Hosts with Suspicious Crons
331
+ - H-0010: Network Connections from Cron-Spawned Processes
332
+ - H-0011: File Execution from Temporary Directories (/tmp, /dev/shm)
333
+ - H-0012: At Job Persistence Mechanisms (T1053.002)
334
+
335
+ ---
336
+
337
+ ## 📊 Results Showcase
338
+
339
+ ### Detection Timeline
340
+
341
+ ```
342
+ 2025-11-17 03:42:15 UTC - Suspicious crontab modification detected
343
+ └─> User "webadmin" modified /var/spool/cron/crontabs/webadmin
344
+ └─> Auditd file integrity monitoring triggered
345
+
346
+ 2025-11-17 03:42:30 UTC - Automated analysis identifies malicious pattern
347
+ └─> Crontab contains curl command to external IP
348
+ └─> Schedule: Every 5 minutes (* * * * *)
349
+ └─> Target IP: 104.xxx.xxx.23 (not in known-good list)
350
+
351
+ 2025-11-17 03:45:00 UTC - First cron job execution observed
352
+ └─> Cron spawned bash process
353
+ └─> Downloaded script from external IP
354
+ └─> Script attempted to establish reverse shell
355
+
356
+ 2025-11-17 04:12:18 UTC - SOC analyst investigation begins
357
+ └─> Incident SOC-2901 created
358
+ └─> Crontab confirmed malicious: cryptominer downloader
359
+
360
+ 2025-11-17 04:30:00 UTC - Containment complete
361
+ └─> Malicious cron entry removed
362
+ └─> webadmin account password reset
363
+ └─> Host isolated for forensic analysis
364
+ ```
365
+
366
+ ### Query Evolution
367
+
368
+ **Iteration 1:** File modification-only detection (Too broad)
369
+ - Query: `auditd file modifications to /var/spool/cron/crontabs/*`
370
+ - **Results:** 89 events - many legitimate user cron updates
371
+ - **Problem:** High noise from legitimate automation and user activities
372
+
373
+ **Iteration 2:** Pattern matching on suspicious commands (Better)
374
+ - Query: Crontab modifications containing curl, wget, bash -c, base64
375
+ - **Results:** 5 events - included backup scripts and monitoring tools
376
+ - **Problem:** False positives from legitimate scripts using similar commands
377
+
378
+ **Iteration 3:** Behavioral analysis with context (Success!)
379
+ - Query: Suspicious commands + unusual schedules + external network connections
380
+ - **Results:** 1 true positive (cryptominer), 1 false positive (backup script)
381
+ - **Success:** Caught malicious persistence within 30 minutes of creation
382
+
383
+ ### Impact Metrics
384
+
385
+ | Metric | Value |
386
+ |--------|-------|
387
+ | **Time to Detection** | 30 minutes from crontab modification |
388
+ | **Time to Investigation** | 2.5 hours (manual analysis) |
389
+ | **Time to Containment** | 4.5 hours total |
390
+ | **Hosts Affected** | 1 (web-prod-07) |
391
+ | **Persistence Duration** | ~48 hours (estimated based on C2 logs) |
392
+ | **Cryptominer Impact** | Prevented: Est. $200/month in cloud compute costs |
393
+ | **False Positives** | 1 (backup script using curl for monitoring) |
394
+ | **Coverage Improvement** | Hunt identified 20% auditd gap in dev environments |
395
+
396
+ ### Key Success Factors
397
+
398
+ 1. **Auditd File Integrity Monitoring:** Real-time detection of crontab modifications
399
+ 2. **Multi-Context Analysis:** Combined file changes + command patterns + network behavior
400
+ 3. **Query Refinement:** 3 iterations reduced FPs from 89 → 1
401
+ 4. **Threat Intel Integration:** C2 IP matched known cryptomining campaign (TI-0089)
402
+ 5. **Baseline Development:** Created whitelist of 200 known-good cron jobs
403
+
404
+ ### Automated Detection Deployed
405
+
406
+ Final query converted to real-time detection rule:
407
+ - **Schedule:** Every 5 minutes
408
+ - **Alert Criteria:**
409
+ - Crontab file modification detected
410
+ - Command contains network activity keywords (curl, wget, nc)
411
+ - Schedule is unusually frequent (< 10 minutes)
412
+ - OR command contains obfuscation (base64, eval, /dev/tcp)
413
+ - **Auto-Response:** Create ticket, snapshot crontab, alert SOC
414
+ - **False Positive Rate:** ~2% (mostly backup scripts, easily whitelisted)
415
+
416
+ ### Lessons Applied from This Hunt
417
+
418
+ **Detection Improvements:**
419
+ - Created baseline of 200 legitimate cron jobs across environment
420
+ - Developed whitelist for known-good patterns (certbot, backup tools, monitoring)
421
+ - Automated cron inventory collection for ongoing baseline comparison
422
+
423
+ **Telemetry Enhancements:**
424
+ - Identified 20% coverage gap in dev/staging (auditd not deployed)
425
+ - Added bash history logging to capture command-line context
426
+ - Implemented network connection correlation for cron processes
427
+
428
+ **Playbook Development:**
429
+ - Documented step-by-step investigation workflow for SOC
430
+ - Created decision tree for cron persistence triage
431
+ - Added automated remediation scripts for common malicious patterns
432
+
433
+ ---
434
+
435
+ **Hunt Completed:** 2025-11-19
436
+ **Next Review:** 2025-12-19 (recurring monthly hunt)