Iniciar sesión

Grouping values

8 min · 2 ejercicio(s)

When one field can have several values, you do not need to repeat the field name. Put the values in parentheses:

http.response.status_code: (401 or 403)
process.name: (whoami.exe or net.exe or nltest.exe)

This is the same as process.name: whoami.exe or process.name: net.exe or …, just shorter and easier to maintain.

You can use and and not inside a group too. On a multi-value field such as event.category this means "the document contains all of these values":

event.type: (start and not end)

Discovery commands

Attackers who land on a machine usually start with discovery: who am I, which groups exist, who are the domain admins? Tools like whoami.exe, net.exe, nltest.exe and systeminfo.exe are classic signals (MITRE ATT&CK T1033, T1069). A value group is perfect to watch for them.

🔎 Profundiza: funciones, errores habituales y práctica

Value groups in detail

field: (a or b or c) is shorthand for field: a or field: b or field: c. Inside the parentheses you can use and, or, not, quotes and wildcards:

process.name: (whoami.exe or "net.exe" or nltest*)
user_agent.original: (*curl* or *python-requests*)

Building watchlists

Value groups are the simplest form of a watchlist. Typical lists in a SOC:

Watchlist Example values
Discovery tools (T1033, T1069, T1082) whoami.exe, net.exe, nltest.exe, systeminfo.exe, ipconfig.exe
LOLBins (living off the land) rundll32.exe, regsvr32.exe, mshta.exe, certutil.exe, bitsadmin.exe
Remote admin tools PsExec*.exe, AnyDesk.exe, TeamViewer.exe
Script hosts powershell.exe, pwsh.exe, wscript.exe, cscript.exe

For long lists use value lists in Elastic Security (rule exceptions) instead of very long KQL strings, so the list can be maintained separately from the rule.

Combine group and context

A tool name alone produces false positives (admins use whoami too). Add context:

process.name: (whoami.exe or net.exe) and process.parent.name: (powershell.exe or cmd.exe) and not user.name: h.yilmaz

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. Denied requests

    How many web requests in lab-web were answered with status 401 or 403?

  2. 2. Discovery commands

    Write a query on lab-endpoint that returns every process start of whoami.exe, net.exe or systeminfo.exe.