Iniciar sesión

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 RENAME or EVAL to align names.
  • Rows without a match keep null in the joined columns, so WHERE threat.name IS NOT NULL keeps 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.

Ejercicios prácticos de esta lección

Resuelve estos ejercicios con una consulta en el laboratorio Elasticsearch real. Inicia sesión gratis para acceder al laboratorio, las pistas y la corrección automática.

  1. 1. What is srv-web-01 talking to?

    Enrich the network events of srv-web-01 with lab-threatintel. Which threat.type do they match?

  2. 2. How long did the upload take?

    How many minutes passed between the first and the last connection to the exfiltration endpoint 91.215.85.12? Return them in a column minutes.