$npx -y skills add meltedinhex/analyst-ai-pack --skill building-zeek-analytics-for-huntingBuilds Zeek-based network hunting analytics by writing scripts and analyzing Zeek logs
| 1 | # Building Zeek Analytics for Hunting |
| 2 | |
| 3 | ## When to Use |
| 4 | |
| 5 | - You have Zeek logs (conn.log, dns.log, http.log, ssl.log, files.log) and want to build hunting |
| 6 | analytics: long-lived connections, rare JA3 fingerprints, suspicious file downloads, and |
| 7 | beaconing. |
| 8 | - You want repeatable detections expressed as Zeek scripts or log-analysis queries. |
| 9 | |
| 10 | **Do not use** Zeek to actively probe hosts — it is passive analysis of captured/sensor traffic. |
| 11 | |
| 12 | ## Prerequisites |
| 13 | |
| 14 | - Zeek logs in TSV or JSON (or a running Zeek sensor). The script analyzes exported logs. |
| 15 | |
| 16 | ## Workflow |
| 17 | |
| 18 | ### Step 1: Analyze a Zeek log for anomalies |
| 19 | |
| 20 | ```bash |
| 21 | python scripts/analyst.py analyze conn.log --kind conn |
| 22 | ``` |
| 23 | |
| 24 | For `conn`, surfaces long-duration and high-byte connections; for `ssl`, counts JA3 rarity; for |
| 25 | `http`, flags executable/script downloads and rare user-agents; for `dns`, flags long/high-entropy |
| 26 | queries. |
| 27 | |
| 28 | ### Step 2: Express the logic as a Zeek script (optional) |
| 29 | |
| 30 | Translate a confirmed pattern into a Zeek script using the appropriate event |
| 31 | (`connection_state_remove`, `ssl_established`, `http_reply`). |
| 32 | |
| 33 | ### Step 3: Confirm |
| 34 | |
| 35 | Corroborate anomalies with destination reputation and other logs (pivot by `uid`). |
| 36 | |
| 37 | ### Step 4: Operationalize |
| 38 | |
| 39 | Stage the Zeek script or scheduled log query as a durable detection. |
| 40 | |
| 41 | ## Validation |
| 42 | |
| 43 | - The analyzer parses both TSV (`#fields`) and JSON Zeek logs. |
| 44 | - Surfaced anomalies match the chosen log kind's fields. |
| 45 | - JA3 rarity and long-connection logic are computed correctly. |
| 46 | |
| 47 | ## Pitfalls |
| 48 | |
| 49 | - TSV header (`#fields`) parsing — column order varies by deployment. |
| 50 | - Backups/updates producing benign long/large connections. |
| 51 | - JA3 collisions across legitimate clients. |
| 52 | |
| 53 | ## References |
| 54 | |
| 55 | - See [`references/api-reference.md`](references/api-reference.md) for the analyzer. |
| 56 | - Zeek docs and log-format references (linked in frontmatter). |