Wildcards and functions
12 min · 2 ejercicio(s)
Wildcards with : and like
process where process.command_line : "*-enc*"
process where process.name like~ ("psexec*.exe", "paexec*.exe")The : operator is the everyday choice for detections: case insensitive and wildcard friendly. Attackers love to change the case of their tools (PoWeRsHeLl.ExE).
Functions
| Function | Example |
|---|---|
startsWith(field, "x") |
startsWith(process.executable, "C:\\Users") |
endsWith(field, "x") |
endsWith~(file.name, ".DOCM") |
stringContains(field, "x") |
stringContains(process.command_line, "MiniDump") |
cidrMatch(field, "cidr", …) |
not cidrMatch(destination.ip, "10.0.0.0/8", "192.168.0.0/16") |
length(field) |
length(process.command_line) > 200 |
substring, between, number, add … |
string and math helpers |
Append ~ to most string functions to make them case insensitive.
Encoded PowerShell
powershell.exe -enc <base64> executes a Base64 encoded command. Legitimate admin scripts rarely do this, malware loaders do it all the time (MITRE ATT&CK T1059.001, T1027).
🔎 Profundiza: funciones, errores habituales y práctica
Function reference (selection)
| Function | Description |
|---|---|
add, subtract, multiply, divide, modulo |
arithmetic |
between(src, left, right) |
text between two strings |
cidrMatch(ip, cidr, …) |
IP in one of the networks |
concat(a, b, …) |
join strings |
endsWith, startsWith, stringContains |
string tests, ~ for case-insensitive |
indexOf(src, find) |
position of a substring |
length(s) |
string length (e.g. very long command lines) |
number(s, base) |
parse a number, also hex |
substring(s, start, end) |
part of a string |
Operators recap
:is case insensitive and supports*and?wildcards. You can pass a list:process.name : ("cmd.exe", "powershell.exe").like/like~andregex/regex~are explicit variants.regexmust match the whole value.==is exact and case sensitive. Prefer:in detections unless you have a reason.
Detection ideas with functions
| Idea | EQL |
|---|---|
| Very long command line (obfuscation) | process where length(process.command_line) > 1000 |
| Binary running from a user folder | process where startsWith~(process.executable, "C:\\Users\\") |
| Double extension | file where file.name : "*.pdf.exe" |
| Non-standard port for a known service | network where process.name : "svchost.exe" and destination.port > 49151 |