Practice: hunting playbook
15 min · 2 ejercicio(s)
A hunt starts with a hypothesis ("someone exfiltrates data over HTTPS"), turns it into a query, and ends with either a finding or a documented "nothing found".
Hunting patterns
| Hypothesis | Query idea |
|---|---|
| Rare outbound destinations | WHERE NOT CIDR_MATCH(destination.ip, "10.0.0.0/8") | STATS c = COUNT(*) BY destination.ip | SORT c ASC |
| Beaconing | STATS c = COUNT(*), started = MIN(@timestamp), ended = MAX(@timestamp) BY process.entity_id, destination.ip and look for many evenly spaced connections |
| Large uploads | STATS sent = SUM(source.bytes) BY host.name, destination.ip | SORT sent DESC |
| Known bad infrastructure | LOOKUP JOIN lab-threatintel ON destination.ip | WHERE threat.name IS NOT NULL |
| Off-hours activity | EVAL h = DATE_EXTRACT("hour_of_day", @timestamp) | WHERE h < 6 OR h >= 22 |
LOOKUP JOIN in short
- The right side must be an index with
index.mode: lookup(here:lab-threatintel). - The join field must have the same name on both sides. Use
RENAMEorEVALto align names. - Rows without a match keep
nullin the joined columns, soWHERE threat.name IS NOT NULLkeeps only hits.
Durations
DATE_DIFF("minute", start, end) returns the number of whole minutes between two dates. Note that first and last are reserved words in ES|QL, so name your columns started and ended instead.