PowerQueries in SentinelOne EDR
Contents
Disclaimer & Intro
For educational and research purposes. These queries are hunting tools, not fire-and-forget alerts. Every org has its own telemetry gaps, schema quirks, and false-positive landscape. Test before you operationalize. Do not push untested detections to production. I do not owe you support.
My blog is my garden.
WARNING: No AI was used in the making of this blog post. Not one token. Just the manual, the docs, and a long afternoon.
Most organizations buy SentinelOne and then use the Threats tab. Something fires, they click into the alert, acknowledge it, move on. Some of them occasionally open Deep Visibility and type a process name into the filter box. They call this threat hunting. They are not threat hunting. They are keyword searching, which is roughly the security equivalent of reading the subject line of your emails and assuming you understood the meeting.
PowerQuery is the actual detection engineering interface inside SentinelOne. It has been sitting there for years. The vast majority of people who have access to it have never written a production-grade query. They either do not know it exists or they opened it once, saw a pipe character, and closed the tab. What the organizations running real detections in SentinelOne have figured out is that PowerQuery is not a search engine. It is a behavioral modeling language. The difference is not cosmetic.
A search asks: "show me PowerShell." A detection models behavior: "show me PowerShell or PowerShell Core where the command line contains encoding, download, AMSI tampering, or stealth flags — summarized by endpoint, user, parent, and risk score." One of those finds every sysadmin running scripts. The other finds attackers. Both use the same underlying data. The gap between them is thinking, not tooling.
This post is my notes on how to actually write PowerQueries. Not the vendor tutorial. Not the onboarding deck. The real workflow, including the parts that break if you do them wrong.
Field Discipline — The Part That Actually Breaks Most Queries
Before syntax. Before logic. Before let variables and scoring and joins. Before any of that, you need to understand SentinelOne's data model or you will spend hours debugging queries that are logically correct but empirically empty.
The problem is src.process and tgt.process. They mean different things depending on event type. In a process creation event, src.process is the creating process (the parent) and tgt.process is the created process (the child). In a network connection event, src.process is the process making the connection. In a file event, src.process is the actor process and tgt.file is the target. In a module load event, src.process loaded module. These are not arbitrary — they follow a logical schema — but if you are coming from Splunk or KQL where the process field is just process_name, you will get this wrong, and your query will return zero rows, and you will blame the data.
Before writing any detection, run this:
endpoint.os = "windows"
| columns timestamp, event_type=event.type, endpoint=endpoint.name,
src_proc=src.process.name, src_cmd=src.process.cmdline,
tgt_proc=tgt.process.name, tgt_cmd=tgt.process.cmdline,
parent=src.process.parent.name
| limit 100
That query asks which sides are actually populated for the events in your tenant. If src_proc is full and tgt_proc is empty, you are looking at events where the process entity lives in src. If the reverse, adjust. Run this for whatever event category you are about to hunt in.
For network activity:
endpoint.os = "windows"
AND (
dst.ip.address != null
OR event.dns.request != null
OR url.address != null
)
| columns timestamp,
endpoint=endpoint.name,
src_ip=src.ip.address,
dst_ip=dst.ip.address,
dst_geo=dst.geo.iso_code,
dns=event.dns.request,
url=url.address,
src_proc=src.process.name,
src_cmd=src.process.cmdline
| limit 100
For registry:
endpoint.os = "windows"
AND registry.keyPath != null
| columns timestamp,
endpoint=endpoint.name,
user=src.process.user,
proc=src.process.name,
cmd=src.process.cmdline,
key=registry.keyPath,
val=registry.value
| limit 100
For file operations:
endpoint.os = "windows"
AND tgt.file.path != null
| columns timestamp,
endpoint=endpoint.name,
user=src.process.user,
proc=src.process.name,
cmd=src.process.cmdline,
path=tgt.file.path,
name=tgt.file.name,
old=tgt.file.oldPath
| limit 100
For module loads:
endpoint.os = "windows"
AND module.path != null
| columns timestamp,
endpoint=endpoint.name,
proc=src.process.name,
proc_path=src.process.image.path,
module=module.name,
module_path=module.path
| limit 100
Run these before you write your actual detection. They cost nothing. They will save you an hour of debugging per query, minimum.
Syntax: Filters, Pipes, Boolean Logic
A PowerQuery is an initial filter expression followed by a pipeline. The filter expression selects rows. The pipeline processes them. Simple:
endpoint.os = 'windows'
AND src.process.name = 'cmd.exe'
| columns timestamp, endpoint=endpoint.name, user=src.process.user,
proc=src.process.name, cmd=src.process.cmdline
| limit 1000
Pipeline commands: columns, let, filter, group, sort, limit. You can chain as many as you need. Early stages reduce data volume. Later stages shape the output.
Use parentheses aggressively. Operator precedence mistakes produce silent bugs — queries that technically run but detect the wrong thing. This is dangerous:
endpoint.os = 'windows'
AND src.process.name = 'cmd.exe'
OR src.process.name = 'powershell.exe'
That parses as "Windows + cmd.exe, or any powershell.exe regardless of OS." Probably not what you meant. Safer:
endpoint.os = 'windows'
AND (
src.process.name = 'cmd.exe'
OR src.process.name = 'powershell.exe'
)
For string matching, the operators matter:
=— exact equality, case-sensitivein:anycase— exact match against a list, case-insensitivecontains:anycase— substring match, case-insensitivematches— regex. Add(?i)inside the regex for case-insensitive matchingendswith— suffix match
Use contains:anycase for command lines, URLs, DNS names, registry values — anything that may vary in case. Use exact match or in:anycase for process names. Use matches when you need word boundaries, optional .exe, or extension groups.
src.process.name in:anycase ("powershell.exe", "pwsh.exe", "powershell_ise.exe")
src.process.cmdline contains:anycase (
"-enc",
"-encodedcommand",
"frombase64string",
"downloadstring",
"invoke-webrequest",
"iex",
"-nop",
"-w hidden",
"amsiutils",
"amsiinitfailed"
)
src.process.cmdline matches "(?i)\\b(vssadmin|wbadmin|bcdedit)(\\.exe)?\\b"
The backslash problem: Windows paths in regex require doubled backslashes in the query string, and doubled again in the regex escape context. A Windows path like \Temp\ becomes \\\\Temp\\\\ in a regex. Test your path regex with a small | columns query before embedding it in detection logic.
NOT works as a prefix or you can use !():
AND NOT (
src.process.name in:anycase ("werfault.exe", "taskmgr.exe", "procmon.exe")
OR src.process.cmdline contains:anycase "crashdump"
)
Use filter after a pipe when you need to filter on a derived let variable:
endpoint.os = 'windows'
| let is_suspicious = src.process.cmdline contains:anycase ("-enc", "downloadstring", "iex")
| filter is_suspicious
| columns timestamp, endpoint=endpoint.name, proc=src.process.name, cmd=src.process.cmdline
| limit 1000
Let Variables: Readable Detection Logic
let is the feature that separates readable detections from regex nightmares. Use it to name conditions, assign derived values, build flags, and score behavior. Without it, complex logic becomes one unreadable line that nobody will maintain.
The readable version of a suspicious PowerShell detection:
endpoint.os = "windows"
AND src.process.name in:anycase ("powershell.exe", "pwsh.exe")
| let encoded = src.process.cmdline contains:anycase (
"-enc", "-encodedcommand", "frombase64string"
)
| let download = src.process.cmdline contains:anycase (
"downloadstring", "invoke-webrequest", "iwr", "wget", "curl"
)
| let stealth = src.process.cmdline contains:anycase (
"-nop", "-w hidden", "-windowstyle hidden", "bypass"
)
| let amsi = src.process.cmdline contains:anycase (
"amsiutils", "amsiinitfailed", "set-mppreference", "add-mppreference"
)
| let hit = encoded OR download OR stealth OR amsi
| filter hit
| columns ts=timestamp, endpoint=endpoint.name, user=src.process.user,
parent=src.process.parent.name, proc=src.process.name, cmd=src.process.cmdline
| limit 1000
Four conditions, four variable names, one hit variable that combines them. The logic reads like English. The detection is tunable because each component is named.
Now add scoring. When individual signals are weak but combinations are strong:
endpoint.os = "windows"
AND src.process.name in:anycase ("powershell.exe", "pwsh.exe", "cmd.exe",
"wscript.exe", "cscript.exe", "mshta.exe")
| let f_enc = src.process.cmdline contains:anycase (
"-enc", "-encodedcommand", "frombase64string"
) ? 1 : 0
| let f_dl = src.process.cmdline contains:anycase (
"downloadstring", "invoke-webrequest", "iwr", "wget", "curl"
) ? 1 : 0
| let f_byp = src.process.cmdline contains:anycase (
"-nop", "-w hidden", "-windowstyle hidden", "bypass"
) ? 1 : 0
| let f_amsi = src.process.cmdline contains:anycase (
"amsiutils", "amsiinitfailed", "set-mppreference", "add-mppreference"
) ? 1 : 0
| let score = f_enc + f_dl + f_byp + f_amsi
| filter score >= 1
| group first_seen=min(timestamp), last_seen=max(timestamp), hits=count(),
score_sum=sum(score)
by endpoint=endpoint.name,
user=src.process.user,
parent=src.process.parent.name,
proc=src.process.name,
cmd=src.process.cmdline
| columns first_seen, last_seen, endpoint, user, parent, proc, cmd, hits, score_sum,
risk = (
score_sum >= 4 ? "HIGH" :
score_sum >= 2 ? "MODERATE" :
"LOW"
)
| sort -score_sum -hits -last_seen
| limit 1000
Scoring works when multiple weak signals combine. It does not work well when one condition is already independently high-confidence — in that case, keep it simple. vssadmin delete shadows /all /quiet does not need a scoring model. Obvious is obvious.
Use let for fallback fields. Real telemetry contains schema variation. Process hashes can appear in multiple fields depending on the agent version and event type:
endpoint.os = "windows"
AND src.process.name in:anycase ("rundll32.exe", "regsvr32.exe", "mshta.exe")
| columns timestamp,
endpoint=endpoint.name,
proc=src.process.name,
cmd=src.process.cmdline,
sha1=(src.process.sha1 || src.process.image.sha1 ||
src.process.hash.sha1 || src.process.file.hash.sha1)
| filter sha1 != null
| group first_seen=min(timestamp), last_seen=max(timestamp), hits=count()
by endpoint, proc, sha1, cmd
| sort -hits -last_seen
| limit 1000
That || chain means: use the first non-null SHA1 value across several possible field locations. This handles schema variation and prevents your query from silently missing events where the hash lives in a different field.
The Production Query Skeleton
Most useful detections follow the same shape:
<early filter: OS, event type, category, broad behavior>
| let <flag1> = <condition>
| let <flag2> = <condition>
| let <hit> = (<flag1> OR <flag2>)
| filter <hit>
| columns <investigation fields>
| group <aggregates> by <entity fields>
| sort <important ordering>
| limit <safe number>
The early filter reduces the dataset before any complex logic runs. let variables make the logic readable and maintainable. filter hit drops everything that did not match. columns builds analyst-ready output. group turns raw event volume into findings. sort and limit make the results operational.
Do not start with joins or complex regex. Start with a field and a behavior. Get something running. Then enrich.
Column ordering matters. Put time and identity first, evidence next, counts last. A sensible order: first_seen, last_seen, endpoint, user, parent, proc, cmd, then evidence fields, then count or risk fields. If someone has to read the left columns to understand the right columns, the design is wrong.
Grouping: Events into Findings
Raw events are noise. Grouping turns noise into signal. The wrong group destroys the signal; the right group makes it visible.
Too little grouping:
| group hits=count() by endpoint.name
This hides which process caused the activity. The analyst cannot investigate from this output.
Too much grouping:
| group hits=count() by timestamp, endpoint.name, src.process.user,
src.process.name, src.process.cmdline
The timestamp makes every row unique. No aggregation happens. You might as well not group.
Balanced grouping for process detections:
| group first_seen=min(timestamp), last_seen=max(timestamp), hits=count()
by endpoint=endpoint.name,
user=src.process.user,
parent=src.process.parent.name,
proc=src.process.name,
cmd=src.process.cmdline
For domain or URL detections:
| group first_seen=min(timestamp), last_seen=max(timestamp), hits=count(),
endpoints=estimate_distinct(endpoint.name),
procs=estimate_distinct(src.process.name)
by dom
estimate_distinct is your cardinality function. Use it to answer "how many unique endpoints touched this domain?" or "how many unique command lines appeared under this process?" High cardinality on either of those numbers is worth investigating.
Summing boolean flags:
endpoint.os = "windows"
AND src.process.name in:anycase ("powershell.exe", "pwsh.exe")
| let f_enc = src.process.cmdline contains:anycase ("-enc", "-encodedcommand") ? 1 : 0
| let f_dl = src.process.cmdline contains:anycase ("downloadstring", "iwr", "wget", "curl") ? 1 : 0
| group hits=count(),
enc_cnt=sum(f_enc),
dl_cnt=sum(f_dl),
score=sum(f_enc + f_dl)
by endpoint=endpoint.name,
user=src.process.user,
proc=src.process.name,
cmd=src.process.cmdline
| sort -score -hits
| limit 1000
Null Handling: The Invisible Failure Mode
Real telemetry contains nulls. A query that ignores them can produce empty groupings, misleading fallback values, or silent misses.
The classic fallback pattern for a normalized IOC field:
event.dns.request contains:anycase "ngrok"
OR url.address contains:anycase "ngrok"
| let dom = event.dns.request != null ? event.dns.request : url.address
| filter dom != null
| group hits=count() by endpoint=endpoint.name, proc=src.process.name, dom
| sort -hits
| limit 1000
If DNS is populated, use it. Otherwise fall back to URL. Then filter out rows where neither was available. Without that last filter dom != null, your group will have a null row that looks like every endpoint with no domain touched this IOC.
Null-safe scoring:
endpoint.os = "windows"
| let cmd = src.process.cmdline != null ? lower(src.process.cmdline) : ""
| let score = (
(cmd contains "-enc" ? 1 : 0) +
(cmd contains "downloadstring" ? 1 : 0) +
(cmd contains "amsi" ? 1 : 0)
)
| filter score > 0
| columns timestamp, endpoint=endpoint.name, proc=src.process.name, cmd, score
| limit 1000
The lower() normalization ensures contains comparison is not case-dependent. The null-to-empty-string substitution prevents the ternary from throwing when cmdline is absent.
Joins: Correlation Across Event Streams
Use joins when you need to correlate two separate streams of data. Not when one stream is enough. Joins are expensive. The right join use cases: process activity correlated to network activity, network destinations enriched with process hash, suspicious logins crossed against endpoint login baseline, ransomware file behavior crossed against process hash.
The syntax:
| join
base = (
<query A>
| columns join_key, fields_from_A
| group aggregates by join_key
),
enrich = (
<query B>
| columns join_key, fields_from_B
| group aggregates by join_key
)
on join_key
| columns final_fields
| sort -important_field
| limit 1000
A useful pattern: suspicious DNS correlated with process hash context:
| join
base = (
endpoint.os = "windows"
AND event.dns.request contains:anycase ("ngrok", "trycloudflare", "localtunnel")
| columns endpoint=endpoint.name,
dns=event.dns.request,
proc=src.process.name,
cmd=src.process.cmdline
| group dns_hits=count() by endpoint, dns, proc, cmd
),
hashes = (
endpoint.os = "windows"
| columns endpoint=endpoint.name,
proc=src.process.name,
sha1=(src.process.sha1 || src.process.image.sha1 ||
src.process.hash.sha1 || src.process.file.hash.sha1)
| filter proc != null OR sha1 != null
| group c=count() by endpoint, proc, sha1
| group common_sha1=max_by(sha1, c) by endpoint, proc
)
on endpoint, proc
| columns endpoint, dns, proc, common_sha1, cmd, dns_hits
| sort -dns_hits
| limit 1000
Keep subqueries filtered before joining. Joining raw high-volume streams is the join equivalent of joining two full tables without a WHERE clause — slow, potentially broken, and generating results that look plausible but are not. Group inside each subquery before the join. Use stable join keys that are unlikely to be null.
Joining on process name alone can mislead: the same process name can correspond to multiple different binaries across different endpoints. Better join keys include endpoint + process + command line, or endpoint + source IP + destination IP, or endpoint + process hash.
Time Windows
A query without a time filter may scan more data than it needs to. Use now() - Nd for relative windows:
| filter timestamp >= now() - 7d
The working nanosecond timestamp pattern, for workflows expecting first.timestamp and last.timestamp in nanosecond resolution:
| group _FirstSeenMs=min(event.time), _LastSeenMs=max(event.time), Count=count()
by endpoint.name, src.process.user, src.process.name, src.process.cmdline
| let _firstSeenNs = _FirstSeenMs * 1000000
| let _lastSeenNs = _LastSeenMs * 1000000
| columns "first.timestamp" = _firstSeenNs,
"last.timestamp" = _lastSeenNs,
endpoint.name,
src.process.user,
src.process.name,
src.process.cmdline,
Count
| sort -Count
| limit 100000
For analyst hunts, first_seen=min(timestamp) and last_seen=max(timestamp) are cleaner. Use the nanosecond conversion when your downstream tooling needs it.
Baselining and Rarity
PowerQuery can do statistical analysis. Mean and standard deviation let you find rare process names in your environment:
endpoint.os = "windows"
AND src.process.name in:anycase (
"at.exe", "bitsadmin.exe", "certutil.exe", "cmd.exe", "cscript.exe",
"mshta.exe", "rundll32.exe", "regsvr32.exe", "wmic.exe", "wscript.exe"
)
| group cnt=count() by proc=src.process.name
| let mean = overall_avg(cnt)
| let var = overall_avg(pow(cnt - mean, 2))
| let sd = sqrt(var)
| let lb = mean - (sd * 1.5)
| filter cnt < lb
| sort cnt
| limit 100
Rare process names are not automatically malicious. certutil.exe might be rare in your environment because nobody uses it legitimately, or because something deleted it, or because the attacker renamed their payload to something else. Rarity is a triage signal, not a verdict.
More useful: rare parent-child relationships:
endpoint.os = "windows"
| group hits=count(), endpoints=estimate_distinct(endpoint.name)
by parent=src.process.parent.name, child=src.process.name
| filter endpoints < 5
| sort endpoints -hits
| limit 1000
Finding parent-child relationships that appear on fewer than five endpoints is a practical way to surface novel or unusual execution chains without knowing in advance what you are looking for. browser.exe spawning rundll32.exe on two endpoints is worth a look. WINWORD.EXE spawning wscript.exe on one endpoint is worth dropping everything for.
Detection Engineering Workflow
A good query does not appear fully formed. Build it in stages and validate at each step. Skipping stages is how you end up with a detection that technically runs but catches the wrong thing.
Stage 1: Validate the telemetry. Run the field validation query for your event type (shown above). Confirm the fields you intend to use are populated in your tenant.
Stage 2: Test the atomic behavior. The simplest possible filter that should match the behavior you are hunting:
endpoint.os = "windows"
AND src.process.cmdline contains:anycase "downloadstring"
| columns timestamp, endpoint=endpoint.name, proc=src.process.name, cmd=src.process.cmdline
| limit 100
Does it return rows? Are they the right rows? If the field is wrong or the data is not there, you will see it here before you have invested time in complex logic.
Stage 3: Add related indicators. Expand from the atomic case to the realistic detection surface:
endpoint.os = "windows"
AND src.process.cmdline contains:anycase (
"downloadstring", "invoke-webrequest", "iwr", "wget", "curl",
"-enc", "-encodedcommand", "frombase64string", "iex"
)
| columns timestamp, endpoint=endpoint.name, user=src.process.user,
parent=src.process.parent.name, proc=src.process.name, cmd=src.process.cmdline
| limit 1000
Stage 4: Add grouping. Turn the event stream into findings:
endpoint.os = "windows"
AND src.process.cmdline contains:anycase (
"downloadstring", "invoke-webrequest", "iwr", "wget", "curl",
"-enc", "-encodedcommand", "frombase64string", "iex"
)
| group first_seen=min(timestamp), last_seen=max(timestamp), hits=count()
by endpoint=endpoint.name, user=src.process.user,
parent=src.process.parent.name, proc=src.process.name, cmd=src.process.cmdline
| sort -hits -last_seen
| limit 1000
Stage 5: Add false-positive handling. Only after seeing real false positives. Not speculatively:
AND NOT (
src.process.parent.name contains:anycase "slack"
OR src.process.parent.name contains:anycase "microsoft"
OR src.process.parent.name contains:anycase "agent"
)
The instinct to pre-exclude broadly because something "sounds noisy" is the instinct that erases malicious variants. False-positive exclusions should be as narrow as the actual false positive. If Slack spawns PowerShell with -enc for some internal reason, exclude that specific parent. Do not exclude all -enc from everything.
Stage 6: Add scoring or correlation if multiple weak signals are in play.
This is where individual flags combine into a risk score. Each condition that is independently weak becomes meaningful when several fire on the same command line. Continuing the PowerShell example from Stages 1-5:
endpoint.os = "windows"
AND src.process.name in:anycase ("powershell.exe", "pwsh.exe")
| let f_enc = src.process.cmdline contains:anycase ("-enc", "-encodedcommand") ? 1 : 0
| let f_dl = src.process.cmdline contains:anycase ("downloadstring", "invoke-webrequest", "iwr", "wget", "curl") ? 1 : 0
| let f_byp = src.process.cmdline contains:anycase ("-nop", "-w hidden", "bypass") ? 1 : 0
| let f_amsi = src.process.cmdline contains:anycase ("amsiutils", "amsiinitfailed") ? 1 : 0
| let score = f_enc + f_dl + f_byp + f_amsi
| filter score >= 1
| group first_seen=min(timestamp), last_seen=max(timestamp), hits=count(),
score_sum=sum(score)
by endpoint=endpoint.name, user=src.process.user,
parent=src.process.parent.name, proc=src.process.name,
cmd=src.process.cmdline
| columns first_seen, last_seen, endpoint, user, parent, proc, cmd, hits,
score_sum,
risk = (
score_sum >= 4 ? "HIGH" :
score_sum >= 2 ? "MODERATE" :
"LOW"
)
| sort -score_sum -hits -last_seen
| limit 1000
f_enc, f_dl, f_byp, f_amsi are binary flags — each is 0 or 1. score is their sum for that event. A command line that has encoded content, download behavior, and a bypass flag scores 3. score_sum=sum(score) accumulates the total score across all matching events for the same command line — if the same cmdline fires 10 times and each time scores 2, score_sum is 20.
The risk column maps the aggregated score to a label the analyst sees immediately without doing mental math: HIGH for score 4+, MODERATE for 2-3, LOW for anything that scored at all but not enough to be confident. Sort descending on score_sum puts the highest-confidence results first.
filter score >= 1 keeps anything with at least one signal. Raise the threshold once you understand your noise floor — filter score >= 2 is a reasonable starting point for many environments. The right threshold is the one that passes real attacks and suppresses your specific false positives, which you can only know after running it.
Do not use scoring when a single condition is independently high-confidence. vssadmin delete shadows /all /quiet does not need a scoring model. Scoring is for situations where the signals are individually ambiguous: suspicious parent + encoded command + download + rare endpoint. All four together mean something. Each one alone might not.
Stage 7: Review results and tune based on evidence. Do not add allowlists blindly.
Before adding any exclusion, ask: is the false positive caused by a known product? A known parent process? A known command line? A known path? A known signer? A known endpoint group? A known domain? Tune the narrowest stable attribute you can find. If the false positive is one specific command line from one specific legitimate tool, exclude that command line — not the parent, not the process name, not the entire behavior.
Good tuning:
AND NOT (
src.process.cmdline contains:anycase "MicrosoftEdgeUpdate"
)
This removes one specific known-benign command line. The detection still fires for everything else.
Bad tuning:
AND NOT (
src.process.name = "powershell.exe"
)
This removes the entire detection. Any PowerShell activity — malicious or not — is now invisible.
Working Detections
These are queries that address real attack patterns. Each includes an explanation of why the logic is shaped the way it is.
Suspicious LSASS Children
lsass.exe should not spawn arbitrary processes. When it does, pay attention.
endpoint.os = 'windows'
AND (
src.process.parent.name = "lsass.exe"
OR src.process.parent.image.path contains:anycase "\\lsass.exe"
)
AND NOT (
src.process.name in:anycase (
"werfault.exe", "taskmgr.exe", "procexp.exe", "procmon.exe",
"csrss.exe", "services.exe", "wininit.exe"
)
OR src.process.cmdline contains:anycase "minidump"
OR src.process.cmdline contains:anycase "crashdump"
)
| group hits=count()
by endpoint=endpoint.name,
user=src.process.user,
parent=src.process.parent.name,
proc=src.process.name,
cmd=src.process.cmdline
| sort -hits
| limit 1000
The check on both parent name and parent image path handles cases where the name field alone may not be reliable. Crash dump tooling (werfault, minidump command lines) is excluded because legitimate crash handling does appear under LSASS. Everything else that appears as a child of LSASS deserves an explanation.
ETW Logging Tampering
Attackers reduce telemetry before doing the noisy parts. This query finds three specific ETW/event-log disablement patterns.
endpoint.os = 'windows'
AND (
(
src.process.name matches "(?i)^wevtutil(\\.exe)?$"
AND src.process.cmdline matches "(?i)\\bsl\\b"
AND (
src.process.cmdline contains "/e:false"
OR src.process.cmdline contains "/enabled:false"
)
)
OR (
src.process.name matches "(?i)^logman(\\.exe)?$"
AND src.process.cmdline matches "(?i)\\bupdate\\b"
AND src.process.cmdline matches "(?i)(-p|--p)"
AND src.process.cmdline matches "(?i)-ets"
)
OR (
src.process.cmdline matches "(?i)\\b(set|remove)-etwtraceprovider\\b"
)
)
AND NOT (
src.process.cmdline matches "(?i)microsoft-windows-printservice"
)
| columns endpoint=endpoint.name,
user=src.process.user,
parent=src.process.parent.name,
proc=src.process.name,
cmd=src.process.cmdline
| group hits=count()
by endpoint, user, parent, proc, cmd
| sort -hits
| limit 1000
Three patterns: wevtutil sl /e:false disables an event log channel. logman update -ets -p modifies an ETW trace session. PowerShell Set-EtwTraceProvider / Remove-EtwTraceProvider cmdlets remove provider subscriptions. Any of these from an unexpected user, parent process, or endpoint role is suspicious. The print service exclusion removes one known benign case. Check parent process, user, endpoint role, timing, and whether this looks like approved troubleshooting.
Ngrok Tunnel
Ngrok used legitimately is a developer convenience tool. Ngrok used by an attacker is an instant RDP tunnel to your network that bypasses your firewall rules by calling out rather than accepting in. The specific ports in this query (445, 3389, 5985, 5986) are the ones worth caring about immediately.
endpoint.os = 'windows'
AND (
src.process.name = "ngrok.exe"
OR src.process.cmdline contains:anycase "ngrok"
OR event.dns.request contains:anycase "ngrok"
OR url.address contains:anycase "ngrok"
)
AND (
src.process.cmdline contains:anycase (" tcp ", " http ", " authtoken ")
OR src.process.cmdline matches "\\btcp\\s+(139|445|3389|5985|5986)\\b"
)
| group _FirstSeenMs=min(event.time), _LastSeenMs=max(event.time), Count=count()
by endpoint.name,
src.process.user,
src.process.parent.name,
src.process.name,
src.process.cmdline,
event.dns.request,
url.address
| let _firstSeenNs = _FirstSeenMs * 1000000
| let _lastSeenNs = _LastSeenMs * 1000000
| columns "first.timestamp" = _firstSeenNs,
"last.timestamp" = _lastSeenNs,
endpoint.name,
src.process.user,
src.process.parent.name,
src.process.name,
src.process.cmdline,
event.dns.request,
url.address,
Count
| sort -Count
| limit 100000
Run Key Persistence from Suspicious Paths
Run and RunOnce keys are commodity persistence. The detection is not "any Run key" — that would drown you in legitimate software startup entries. The detection is "Run key pointing to a writable location or a scriptable file type":
endpoint.os = 'windows'
AND (
(
registry.keyPath matches "(?i)\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\(Run|RunOnce|Policies\\\\Explorer\\\\Run)(\\\\|$)"
AND registry.value matches "(?i)(\\\\Windows\\\\Temp\\\\|\\\\ProgramData\\\\|Recycle\\.bin\\\\|AppData\\\\|\\\\Temp\\\\|\\\\Users\\\\Public\\\\|\\\\Users\\\\Default\\\\|wscript|script).*(\\.exe|\\.cmd|\\.bat|\\.vbs|\\.ps1)"
)
OR (
src.process.cmdline matches "(?i)\\breg(\\.exe)?\\s+add\\s+.*microsoft\\\\windows\\\\currentversion.*(/f|/v).*reg_sz.*c:\\\\users\\\\.*\\.exe.*(\\\\run|\\\\policies\\\\explorer\\\\run|\\\\runonce)"
)
)
AND NOT (
registry.value contains:anycase (
'atlassian', 'Agent', 'BlueJeans', 'Cisco', 'Discord', 'Dropbox', 'Docker',
'GoToMeeting', 'Lifesize', 'Edge Update', 'OneDrive', 'slack', 'Teams',
'VMware', 'MicrosoftSaRA', 'Intel', 'Java', 'Adobe'
)
OR src.process.image.path contains:anycase (
'atlassian', 'dropbox', 'onedrivesetup.exe', 'sara.exe'
)
)
| columns timestamp,
endpoint=endpoint.name,
user=src.process.user,
parent=src.process.parent.name,
proc=src.process.name,
cmd=src.process.cmdline,
key=registry.keyPath,
val=registry.value
| group hits=count()
by endpoint, user, parent, proc, key, val, cmd
| sort -hits
| limit 1000
The allowlist contains known enterprise applications that legitimately create Run key entries. The detection logic is behavior plus location plus file type, not just "Run key written." False positives should be tuned by adding specific names to the allowlist with evidence. Remove the entire allowlist and you will be busy for weeks.
Remote Access / RMM Domain Detection
Unauthorized RMM tools are everywhere in modern intrusions. BishopFox, Mandiant, every ransomware IR report from the last four years names at least one. This query hunts the domain patterns:
endpoint.os = 'windows'
AND (
event.dns.request matches "(?i)(teamviewer\\.com|logmein(rescue|inc)?\\.com|getgo\\.com|goto(mypc|assist)?\\.com|anydesk\\.com|screenconnect|connectwise\\.com|splashtop(\\.eu)?\\.com|rustdesk\\.com|radmin\\.com|zohoassist|bomgar|beyondtrustcloud\\.com|dameware\\.com|remote\\.it|atera\\.com|kaseya\\.com|auvik\\.com|datto\\.com|ninjarmm|ninjaone\\.com|n-central|centrastage\\.net|syncromsp\\.com|action1agent|action1\\.com|jumpcloud\\.com|mesh(agent|central)|getscreen\\.me|supremo\\.control|royalapps\\.com|iperiusremote\\.com|ultravnc\\.com|tightvnc\\.com|realvnc\\.com|parsec\\.(app|gg)|tailscale\\.com|anyviewer\\.com)"
OR url.address matches "(?i)(teamviewer\\.com|logmein(rescue|inc)?\\.com|getgo\\.com|goto(mypc|assist)?\\.com|anydesk\\.com|screenconnect|connectwise\\.com|splashtop(\\.eu)?\\.com|rustdesk\\.com|radmin\\.com|zohoassist|bomgar|beyondtrustcloud\\.com|dameware\\.com|remote\\.it|atera\\.com|kaseya\\.com|auvik\\.com|datto\\.com|ninjarmm|ninjaone\\.com|n-central|centrastage\\.net|syncromsp\\.com|action1agent|action1\\.com|jumpcloud\\.com|mesh(agent|central)|getscreen\\.me|supremo\\.control|royalapps\\.com|iperiusremote\\.com|ultravnc\\.com|tightvnc\\.com|realvnc\\.com|parsec\\.(app|gg)|tailscale\\.com|anyviewer\\.com)"
)
| columns timestamp,
endpoint=endpoint.name,
dns=event.dns.request,
url=url.address,
proc=src.process.name,
cmd=src.process.cmdline
| let ioc = dns != null ? dns : url
| group first_seen=min(timestamp),
last_seen=max(timestamp),
hits=count(),
endpoints=estimate_distinct(endpoint)
by endpoint, ioc, proc
| sort -hits -last_seen
| limit 100000
The ioc field normalizes DNS and URL into a single column for easier review. Results need to be compared against your approved remote access tooling. If your org uses TeamViewer legitimately, add it to an exclusion. Every other hit deserves a question about who installed it, why, and when.
Tunnel Service Domains
The ngrok query covers one tunnel service. This covers the broader population. Different from the ngrok query in that it searches on network indicators, not command-line syntax — which means it also catches renamed binaries and browser-based tunnel usage:
(
event.dns.request contains (
"shellhub.io", "tuns.sh", "pagekite.net", "loca.lt", "localtunnel.me",
"dataplicity.com", "devtunnels.ms", "tunnels.api.visualstudio.com",
"telebit.cloud", "localhost.run", "pinggy.io", "pinggy.link",
"loophole.site", "burrow.io", "localto.net", "localtonet.com",
"tmate.io", "jprq.io", "bore.pub", "bore.digital", "btunnel.in",
"ngrok.com", "ngrok.io", "ngrok.dev", "ngrok.pro", "ngrok.pizza",
"serveo.net", "pitunnel.com", "openport.io", "beeceptor.com",
"localxpose.io", "expose.sh", "expos.es", "trycloudflare.com",
"cfargotunnel.com", "cftunnel.com"
)
OR url.address contains (
"shellhub.io", "tuns.sh", "pagekite.net", "loca.lt", "localtunnel.me",
"dataplicity.com", "devtunnels.ms", "tunnels.api.visualstudio.com",
"telebit.cloud", "localhost.run", "pinggy.io", "pinggy.link",
"loophole.site", "burrow.io", "localto.net", "localtonet.com",
"tmate.io", "jprq.io", "bore.pub", "bore.digital", "btunnel.in",
"ngrok.com", "ngrok.io", "ngrok.dev", "ngrok.pro", "ngrok.pizza",
"serveo.net", "pitunnel.com", "openport.io", "beeceptor.com",
"localxpose.io", "expose.sh", "expos.es", "trycloudflare.com",
"cfargotunnel.com", "cftunnel.com"
)
)
| columns timestamp,
endpoint=endpoint.name,
user=src.process.user,
proc=src.process.name,
cmd=src.process.cmdline,
dns=event.dns.request,
url=url.address
| let dom = dns != null ? dns : url
| filter dom != null
| group first=min(timestamp),
last=max(timestamp),
hits=count(),
uniq_procs=estimate_distinct(proc)
by endpoint, user, proc, dom
| sort -hits -last
| limit 1000
High-risk results: tunnel domains accessed by service accounts, servers, PowerShell, Python, unknown binaries, or any endpoint that has no business running a developer tunnel tool.
WMIC Security Product Discovery
Attackers query WMI for security product information before deciding which payload to use or which defenses to try to disable. This is common enough to appear in threat intelligence for threat groups across all industries:
endpoint.os = 'windows'
AND (
src.process.name = "wmic.exe"
OR src.process.cmdline contains:anycase "wmic"
)
AND src.process.cmdline matches "(?i)(antivirus|securitycenter|securityproduct|namespace|AntiVirusProduct|SecurityCenter2)"
| columns timestamp,
endpoint=endpoint.name,
user=src.process.user,
parent=src.process.parent.name,
proc=src.process.name,
cmd=src.process.cmdline
| group hits=count()
by endpoint, user, parent, proc, cmd
| sort -hits
| limit 1000
False positives: inventory tools, EDR health checks, vulnerability scanners. Tune by parent process and known management tool paths. Do not remove WMIC from the detection entirely.
Sysinternals EULA Acceptance
Not a malware alert. A tool introduction signal. The first time someone runs a Sysinternals tool on an endpoint, it writes an EulaAccepted registry key. That event tells you when and where someone introduced PsExec, ProcDump, Handle, or any other Sysinternals binary. Combined with LSASS access or remote service creation, it becomes significant:
endpoint.os = 'windows'
AND (
registry.value matches "(?i)^EulaAccepted$"
OR registry.keyPath matches "(?i)\\\\Software\\\\Sysinternals\\\\[^\\\\]+\\\\EulaAccepted"
OR src.process.cmdline matches "(?i)(^|\\s)-accepteula(\\s|$)"
)
| columns timestamp,
endpoint=endpoint.name,
user=src.process.user,
parent=src.process.parent.name,
proc=src.process.name,
cmd=src.process.cmdline,
key=registry.keyPath,
val=registry.value
| group hits=count()
by endpoint, user, parent, proc, cmd
| sort -hits
| limit 1000
Investigate who ran the tool, from what parent, on what endpoint role, and whether the endpoint should have Sysinternals binaries appearing for the first time. Cross-reference with other indicators from the same time window.
Telegram C2 Indicators
Telegram's Bot API is a C2 channel. The pattern is well-documented: attacker stands up a bot, the implant communicates via api.telegram.org over HTTPS. The traffic looks identical to legitimate Telegram use, which is the entire point.
This query watches both DNS and URL telemetry for the two endpoints. Both api.telegram.org and t.me/ appear in real campaigns.
(event.category = "dns" OR event.category = "url")
AND (
event.dns.request contains:anycase "api.telegram.org"
OR url.address contains:anycase "api.telegram.org"
OR url.address contains:anycase "t.me/"
)
| let proc_name = src.process.name
| let proc_path = src.process.image.path
| let parent_name = src.process.parent.name
| let cmd = src.process.cmdline
| group hits=count(),
endpoints=count_distinct(endpoint.name),
last_seen=max(timestamp)
by proc_name, proc_path, parent_name, cmd
| sort hits asc
| limit 100
Sort ascending by design. Browsers legitimately hit api.telegram.org hundreds of times per session — they sink to the bottom. The implant that ran from %TEMP% and fired once floats to the top. If chrome.exe or msedge.exe is your entire result set, the detection is working. If explorer.exe appears with a count of 2, that is the lead.
The trailing slash in t.me/ prevents partial matches on unrelated domains that happen to contain the string "t.me".
Suspicious Execution from User-Writable Paths
Legitimate software installs to C:\Program Files or C:\Windows. When an attacker drops a payload, it goes somewhere they control without elevated privilege: Temp, AppData, Public, Downloads, the Recycle Bin. These locations exist on every Windows system.
Path-based detection is harder to evade than name-based detection. Renaming a binary changes src.process.name. It does not change src.process.image.path.
event.category = "process"
AND src.process.image.path matches:anycase ".*\\\\(temp|windows\\\\temp|appdata|users\\\\public|programdata\\\\temp|recycler|\\$recycle\\.bin|downloads|desktop)\\\\.*"
AND NOT src.process.image.path matches:anycase ".*\\\\(Microsoft|WindowsApps|Google\\\\Chrome|Mozilla Firefox|Adobe|Dropbox|OneDrive|Teams|Zoom|Spotify)\\\\.*"
| let proc_name = src.process.name
| let proc_path = src.process.image.path
| let parent_name = src.process.parent.name
| let cmd = src.process.cmdline
| let user = src.process.user
| group hits=count(),
endpoints=count_distinct(endpoint.name),
last_seen=max(timestamp)
by proc_name, proc_path, parent_name, cmd, user
| sort hits asc
| limit 100
The allowlist covers software that legitimately stages files in AppData or Temp during updates. Add your enterprise software by full path pattern, not by process name. A process named updater.exe in C:\Program Files\Vendor\ is different from the same name in %APPDATA%.
Use :anycase on path comparisons. The agent stores paths as-is from the OS, and older telemetry versions sometimes include lowercase paths that case-sensitive matching would miss.
Headless Browser Execution
Chromium's --headless flag is standard web automation and a documented malware technique. The binary, the flag, and the process name are identical in both cases. What differs is context — what launched it, from which path, and which arguments it passed.
The --remote-debugging-port flag is the one worth singling out. It exposes the DevTools Protocol over a local TCP port. Attackers use this to pull saved credentials out of browser session storage without touching the disk.
event.category = "process"
AND src.process.name matches:anycase "^(chrome|msedge|chromium)(\\.exe)?$"
AND src.process.cmdline matches:anycase ".*(--headless|--dump-dom|--remote-debugging-port|--disable-gpu|--no-sandbox).*"
AND NOT (
src.process.parent.name in:anycase ("jenkins", "teamcity", "node", "python", "selenium", "pytest")
OR src.process.image.path matches:anycase ".*\\\\(Program Files|Program Files \\(x86\\))\\\\Google\\\\Chrome\\\\.*"
)
| let proc_path = src.process.image.path
| let parent_name = src.process.parent.name
| let parent_path = src.process.parent.image.path
| let cmd = src.process.cmdline
| let user = src.process.user
| group hits=count(),
endpoints=count_distinct(endpoint.name),
last_seen=max(timestamp)
by proc_path, parent_name, parent_path, cmd, user
| sort hits asc
| limit 100
The parent exclusions cover CI/CD and test frameworks that legitimately drive headless browsers. The path exclusion catches Chrome installed to Program Files — if headless Chrome is running from %APPDATA% or %TEMP%, the path exclusion does not apply and the detection still fires.
Suspicious TLD with Risky File Extension
Cheap disposable TLDs host a disproportionate share of malware staging infrastructure. When a URL on one of those TLDs is serving a directly executable file type, the combination drops the noise floor significantly. Either signal alone fires constantly. Together, the false positive rate becomes workable.
event.category = "url"
AND url.address matches:anycase ".*\\.(xyz|top|tk|ml|cf|ga|pw|su|ru|info)(:|/).*\\.(zip|iso|img|exe|dll|bat|ps1|vbs|js|hta|lnk)(\\?.*)?$"
AND NOT (
src.process.name in:anycase ("chrome.exe", "firefox.exe", "msedge.exe", "opera.exe")
AND url.address matches:anycase ".*(ru|su)(:|/).*\\.js$"
)
| let url = url.address
| let proc_name = src.process.name
| let proc_path = src.process.image.path
| let parent_name = src.process.parent.name
| let user = src.process.user
| group hits=count(),
endpoints=count_distinct(endpoint.name),
last_seen=max(timestamp)
by url, proc_name, proc_path, parent_name, user
| sort hits asc
| limit 100
The exclusion covers browsers hitting .ru or .su JavaScript files, which can be legitimate CDN traffic. Adjust based on your organization's actual traffic patterns.
.ru and .su appear consistently in malware staging analysis. This is not a geopolitical block — it is a risk signal to review in context. If your organization has documented Russian-language user traffic, tune accordingly and document why.
SmartScreen Disablement
Windows SmartScreen is not a high-quality control, but it is a consistent attacker target because it prevents execution of unsigned or low-reputation binaries. Disabling it is a documented step in Agent Tesla loaders, commodity RAT droppers, and plenty of crimeware that never gets a threat report because it is too boring to write about.
The registry path is HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WDSI\Capabilities or the policy path under SOFTWARE\Policies\Microsoft\Windows\System. The value is EnableSmartScreen or SmartScreenEnabled depending on Windows version. Malware sets it to 0 or the string "Off".
event.category = "registry"
AND registry.keyPath matches:anycase ".*(SmartScreen|WDSI\\\\Capabilities).*"
AND (
registry.value matches:anycase "^(EnableSmartScreen|SmartScreenEnabled)$"
OR registry.keyPath matches:anycase ".*WDSI\\\\Capabilities.*"
)
AND (
registry.data = "0"
OR registry.data contains:anycase "off"
)
| let proc_name = src.process.name
| let proc_path = src.process.image.path
| let parent_name = src.process.parent.name
| let cmd = src.process.cmdline
| let reg_key = registry.keyPath
| let reg_value = registry.value
| let reg_data = registry.data
| group hits=count(),
endpoints=count_distinct(endpoint.name),
last_seen=max(timestamp)
by proc_name, proc_path, parent_name, cmd, reg_key, reg_value, reg_data
| sort hits asc
| limit 100
Legitimate SmartScreen configuration through Group Policy takes a different code path and does not typically generate individual endpoint registry events in the same pattern. If an endpoint management tool (SCCM, Intune) shows up here, add its binary path to an exclusion and document the reason and review date.
Indicator Volume Hunting
SentinelOne's agent attaches Indicators to events as behavioral tags from the detection engine. Most teams review these through the Incidents panel after the fact. This query gives a cross-endpoint view of indicator activity so you can spot coordinated campaigns and spikes before they turn into incidents.
indicator.category != null
AND indicator.category != "General"
| let ind_cat = indicator.category
| let ind_name = indicator.name
| let proc_name = src.process.name
| let proc_path = src.process.image.path
| let user = src.process.user
| group hits=count(),
endpoints=count_distinct(endpoint.name),
users=count_distinct(user),
last_seen=max(timestamp)
by ind_cat, ind_name, proc_name, proc_path
| sort endpoints desc
| limit 100
Sort by endpoints desc to surface indicators hitting the most machines. One indicator on one endpoint is a potential threat. The same indicator on forty endpoints in a 30-minute window is an active campaign.
The "General" exclusion removes a high-volume catch-all category that fires on near-everything. Add other noisy categories as you learn your baseline. Run it without the exclusion first to see what dominates, then add targeted exclusions with documented reasons.
Suspicious PowerShell Correlated with External Connections
PowerShell connecting to external infrastructure is not inherently malicious — Windows Update, Defender, legitimate automation all do this. The signal is which PowerShell instances connect to which countries in which context. This join correlates PowerShell process events with network events, strips RFC1918 space, and filters to countries outside your expected baseline.
Read this one section by section.
event.category = "process"
AND src.process.name contains:anycase "powershell"
AND NOT (
src.process.cmdline contains:anycase "WindowsUpdate"
OR src.process.cmdline contains:anycase "MpCmdRun"
OR src.process.cmdline contains:anycase "SCCM"
OR src.process.cmdline contains:anycase "Defender"
OR src.process.cmdline contains:anycase "PSWindowsUpdate"
)
| let ps_endpoint = endpoint.name
| let ps_pid = src.process.pid
| let ps_user = src.process.user
| let ps_cmd = src.process.cmdline
| join (
event.category = "ip"
AND dst.ip.address != null
AND !net_private(dst.ip.address)
| let country = geo_ip_country(dst.ip.address)
| let net_endpoint = endpoint.name
| let net_pid = src.process.pid
| let dst_ip = dst.ip.address
| let dst_port = dst.port
) on ps_endpoint = net_endpoint AND ps_pid = net_pid
| filter country != null
| filter country not in ("US", "IN", "GB")
| group hits=count(),
endpoints=count_distinct(ps_endpoint),
countries=array_agg_distinct(country),
ips=array_agg_distinct(dst_ip),
last_seen=max(timestamp)
by ps_user, ps_cmd, ps_endpoint
| sort hits asc
| limit 100
The filter country not in ("US", "IN", "GB") line is the mandatory customization. Put your organization's expected countries there. If your user base is entirely North American, filter out "US" and "CA". If you have EU offices, add "DE", "FR", "NL". Leaving the defaults generates false positives for every Microsoft cloud service that geolocates outside those three countries.
The join key is ps_endpoint = net_endpoint AND ps_pid = net_pid. This links the specific PowerShell process by PID on the same endpoint that made the network connection. PID reuse is real — always join on both endpoint and PID together, never PID alone.
array_agg_distinct(country) returns a deduplicated list of all destination countries per PowerShell command line. A result showing ["RU", "CN", "IR"] for an encoded command invocation is an immediate escalation. A result showing ["US"] for a recognizable Windows Update cmdlet is an allowlist candidate.
Failed Logins Followed by Successful Login
Brute force followed by success is obvious in hindsight and invisible in real time because the failures are noise. This query joins failed login events with a subsequent success from the same user on the same endpoint within a 30-minute window.
event.category = "login"
AND event.login.result = "FAILED"
AND event.login.userName != null
| let fail_endpoint = endpoint.name
| let fail_user = event.login.userName
| let fail_src_ip = event.login.networkSource.ip
| let fail_time = timestamp
| join (
event.category = "login"
AND event.login.result = "SUCCESS"
AND event.login.userName != null
| let succ_endpoint = endpoint.name
| let succ_user = event.login.userName
| let succ_src_ip = event.login.networkSource.ip
| let succ_time = timestamp
) on fail_endpoint = succ_endpoint AND fail_user = succ_user
| filter succ_time > fail_time
| let time_to_success_minutes = (succ_time - fail_time) / 60000
| filter time_to_success_minutes < 30
| group fail_count=count(),
endpoints=count_distinct(fail_endpoint),
first_fail=min(fail_time),
first_success=max(succ_time),
time_to_success_min=min(time_to_success_minutes)
by fail_user, fail_endpoint, fail_src_ip
| sort fail_count desc
| limit 100
The time_to_success_min field is the window between first failure and eventual success. A value of 1 with a fail_count of 400 is credential stuffing that worked. A value of 25 with a fail_count of 3 is a user who forgot their password twice before getting it right. The number and the timing together tell the story.
event.login.userName != null is required in both sides of the join. Null usernames exist in the login stream for system-level authentication events. Without the null filter, those rows will match on the join condition and generate spurious results.
fail_src_ip in the output is the critical context. All failures from 192.168.1.100 followed by success from the same internal IP is local brute force. Failures from an AWS IP block followed by success from a VPN IP 20 minutes later is credential stuffing with proxy rotation. The source IP determines the response.
Limits: A Note on Reasonable Numbers
Use limit 100 when testing. Use limit 1000 for focused hunts. Use limit 100000 for broad grouped exports — but only after filtering and grouping, not before.
This is wrong:
endpoint.os = "windows"
| limit 100
| group hits=count() by src.process.name
That limits before grouping. You are grouping 100 rows, not the population. The result is meaningless. limit belongs at the end of the pipeline, after sorting.
Always sort before limit. A query without sort returns arbitrary rows. For high-frequency detections, sort descending by hit count and last seen. For rare behavior hunts, sort ascending by hit count. For incident response, sort by last seen descending to see the most recent activity first.
Tuning: Cut Noise Without Breaking the Detection
Every detection that ships to production generates false positives. If yours does not, either the detection is too narrow to catch real attacks, or you have the quietest environment in the world. Tuning is part of the process, not a sign that the detection is broken.
Start with evidence, not instinct. Before adding an exclusion, verify why the false positive fires. If it fires because a specific legitimate binary has the same behavior as the attacker technique, exclude that binary by full image path. Not by name. Not by parent. By the full path. A process named updater.exe running from %TEMP% is not the same as updater.exe running from C:\Program Files\Vendor\.
Path-based exclusions survive binary renames. Name-based exclusions do not.
AND NOT (
src.process.image.path matches:anycase ".*\\\\Program Files\\\\Vendor XYZ\\\\updater\\.exe"
OR src.process.image.path matches:anycase ".*\\\\Program Files \\(x86\\)\\\\Vendor XYZ\\\\updater\\.exe"
)
Document your exclusions. A comment above each exclusion line stating what it covers and when you added it takes thirty seconds and saves the next person hours:
AND NOT (
// Vendor XYZ patch service - drops temp files during update cycle; reviewed 2026-06
src.process.image.path matches:anycase ".*\\\\Program Files\\\\Vendor XYZ\\\\updater\\.exe"
)
Six months later that comment is the difference between "this exclusion is correct" and "I have no idea why we added this."
Tune by score before tuning by exclusion. For scored detections that use ? 1 : 0 flags summed into a total score, investigate what score the false positives hit before reaching for path exclusions. If everything that should not fire scores 2 out of a possible 5, raise the threshold to 3. That single number change is cleaner than a list of path exclusions that grows every quarter.
Exclude by endpoint group, not by hostname. If a detection fires on IT endpoints because IT legitimately runs administrative tools, the fix is not to exclude specific hostnames — those change. Tag the endpoints in SentinelOne with a management group or filter tag and exclude the group. Hostname exclusions are maintenance debt that silently expires when machines are re-imaged.
Set a review date. Every exclusion should have a date after which it gets re-evaluated. Software versions change. Processes that staged files in Temp last year may install correctly to Program Files now. Quarterly review of the exclusion list is not optional if you want the detection to stay accurate.
Common Patterns by Attack Technique
These are the query skeletons I keep returning to. Not finished detections — starting points that cover the most common pattern per technique. Take each one, validate the fields in your environment, add your allowlist entries, and build from there.
Living-Off-The-Land Binaries
LOLBins are Windows-signed system binaries that attackers repurpose for execution, download, and decode operations. The binary is legitimate. The usage is not.
event.category = "process"
AND src.process.name in:anycase (
"certutil.exe", "mshta.exe", "wscript.exe", "cscript.exe",
"regsvr32.exe", "rundll32.exe", "msiexec.exe", "installutil.exe",
"msbuild.exe", "cmstp.exe", "mavinject.exe", "xwizard.exe",
"odbcconf.exe", "ieexec.exe", "msdeploy.exe"
)
AND (
src.process.cmdline matches:anycase ".*(http:|https:|\\\\(temp|appdata|public|programdata)\\\\|decode|encode|urlcache).*"
OR src.process.parent.name not in:anycase (
"explorer.exe", "services.exe", "msiexec.exe", "svchost.exe",
"wmiprvse.exe", "dllhost.exe", "taskhost.exe", "taskhostw.exe"
)
)
| group hits=count(),
endpoints=count_distinct(endpoint.name),
last_seen=max(timestamp)
by src.process.name, src.process.cmdline, src.process.parent.name,
src.process.image.path, endpoint.name
| sort hits asc
| limit 100
Browser Spawning Suspicious Child Process
Browsers do not spawn PowerShell. If one does, it is either a malicious document, a browser exploit, or malware using the browser as a launcher. None of these are acceptable outcomes.
event.category = "process"
AND src.process.parent.name in:anycase (
"chrome.exe", "firefox.exe", "msedge.exe",
"iexplore.exe", "opera.exe", "brave.exe"
)
AND src.process.name in:anycase (
"powershell.exe", "pwsh.exe", "cmd.exe", "wscript.exe", "cscript.exe",
"mshta.exe", "regsvr32.exe", "rundll32.exe", "certutil.exe", "bitsadmin.exe"
)
| group hits=count(),
endpoints=count_distinct(endpoint.name),
last_seen=max(timestamp)
by src.process.name, src.process.cmdline,
src.process.parent.name, src.process.parent.cmdline, endpoint.name
| sort hits asc
| limit 100
Office Spawning Script Interpreter
Office spawning a script interpreter is the most-detected initial access technique that organizations still miss at scale because the allowlist to suppress it is longer than the detection itself. The answer is not to suppress — it is to tune the cmdline to remove known-good patterns and alert on the rest.
event.category = "process"
AND src.process.parent.name in:anycase (
"winword.exe", "excel.exe", "powerpnt.exe", "outlook.exe",
"onenote.exe", "msaccess.exe", "mspub.exe", "visio.exe"
)
AND src.process.name in:anycase (
"powershell.exe", "pwsh.exe", "cmd.exe", "wscript.exe",
"cscript.exe", "mshta.exe", "regsvr32.exe", "rundll32.exe",
"certutil.exe", "bitsadmin.exe", "curl.exe", "wget.exe"
)
| group hits=count(),
endpoints=count_distinct(endpoint.name),
last_seen=max(timestamp)
by src.process.name, src.process.cmdline,
src.process.parent.name, src.process.parent.cmdline, endpoint.name
| sort hits asc
| limit 100
Credential Dumping Strings in Command Line
Every credential dumping tool leaves detectable strings in its command line. The tools change. The strings remain consistent across campaigns.
event.category = "process"
AND src.process.cmdline matches:anycase ".*(sekurlsa|logonpasswords|lsadump|dcsync|ntds\\.dit|sam\\.hive|procdump.*lsass|minidump.*lsass|comsvcs.*minidump|MiniDump.*lsass|Out-Minidump|pypykatz|impacket).*"
| group hits=count(),
endpoints=count_distinct(endpoint.name),
last_seen=max(timestamp)
by src.process.name, src.process.cmdline,
src.process.parent.name, src.process.user, endpoint.name
| sort hits asc
| limit 100
Shadow Copy Deletion
Shadow copy deletion is ransomware precondition one. Every major ransomware family targets shadow copies. This fires on all three common deletion methods — vssadmin, WMIC, and PowerShell direct WMI.
event.category = "process"
AND (
(
src.process.name in:anycase ("vssadmin.exe", "diskshadow.exe")
AND src.process.cmdline matches:anycase ".*(delete|resize shadowstorage|shadows).*"
)
OR (
src.process.name = "wmic.exe"
AND src.process.cmdline matches:anycase ".*shadowcopy.*delete.*"
)
OR (
src.process.name in:anycase ("powershell.exe", "pwsh.exe")
AND src.process.cmdline matches:anycase ".*(Win32_ShadowCopy|Delete-Volume|Get-WmiObject.*shadow|Get-CimInstance.*shadow).*"
)
)
| group hits=count(),
endpoints=count_distinct(endpoint.name),
last_seen=max(timestamp)
by src.process.name, src.process.cmdline,
src.process.parent.name, src.process.user, endpoint.name
| sort hits asc
| limit 100
Suspicious Module Load from Temp Path
DLLs loaded from Temp or AppData are a persistent indicator of process injection, side-loading, and in-memory staging. Legitimate DLLs install to System32 or vendor program directories.
event.category = "module"
AND module.path matches:anycase ".*\\\\(temp|windows\\\\temp|appdata\\\\local\\\\temp|users\\\\public|programdata)\\\\.*\\.(dll|so)$"
AND NOT module.path matches:anycase ".*(MicrosoftEdge|chrome|firefox|MsSpellCheckingFacility|nvidia|intel|amd|realtek).*"
| group hits=count(),
endpoints=count_distinct(endpoint.name),
last_seen=max(timestamp)
by module.path, src.process.name, src.process.image.path, endpoint.name
| sort hits asc
| limit 100
Suspicious Registry Shell Open Command
Hijacking shell open commands lets an attacker redirect execution of specific file types to their own binary. When a user opens a .bat file, Windows checks the shell open command registered for .bat in the registry. If an attacker modified it, their binary runs instead.
event.category = "registry"
AND registry.keyPath matches:anycase ".*\\\\shell\\\\open\\\\command.*"
AND registry.data matches:anycase ".*\\\\(temp|appdata|public|programdata|users\\\\default)\\\\.*"
AND NOT (
registry.keyPath matches:anycase ".*(HKLM|Classes).*\\\\(html|htm|pdf|http|https).*"
AND src.process.name in:anycase (
"chrome.exe", "msedge.exe", "firefox.exe",
"AcroRd32.exe", "Acrobat.exe"
)
)
| group hits=count(),
endpoints=count_distinct(endpoint.name),
last_seen=max(timestamp)
by registry.keyPath, registry.value, registry.data,
src.process.name, src.process.image.path, endpoint.name
| sort hits asc
| limit 100
Suspicious Scheduled Task via Registry
Task Scheduler stores configuration under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks. Registry-based task creation bypasses schtasks.exe and at.exe entirely, so process-based detections for task creation miss it. This catches the registry write directly.
event.category = "registry"
AND registry.keyPath matches:anycase ".*\\\\Schedule\\\\TaskCache\\\\(Tasks|Tree)\\\\.*"
AND (
registry.value = "Actions"
OR registry.value = "Triggers"
)
AND NOT (
src.process.name in:anycase (
"svchost.exe", "taskhost.exe", "taskhostw.exe",
"WmiPrvSE.exe", "mmc.exe", "taskschd.exe"
)
AND src.process.image.path matches:anycase ".*\\\\Windows\\\\(System32|SysWOW64)\\\\.*"
)
| group hits=count(),
endpoints=count_distinct(endpoint.name),
last_seen=max(timestamp)
by registry.keyPath, registry.value, registry.data,
src.process.name, src.process.image.path,
src.process.parent.name, endpoint.name
| sort hits asc
| limit 100
Performance Rules
PowerQuery runs against large datasets. The order of operations in your pipeline directly affects how much data each step processes.
Filter first, transform later. Every filter you add before a | let or | group reduces the row count that subsequent operations see. Open with the most specific filter you have. A query that starts with event.category = "process" and immediately narrows by process name is cheaper than one that processes all process events and filters at the end.
Avoid regex when exact match works. src.process.name = "powershell.exe" is faster than src.process.name matches "(?i)powershell". Use matches for patterns that require regex. Use = or contains:anycase for string comparisons where you know the full value or substring.
Join on low-cardinality keys. Joining on endpoint.name AND src.process.pid is reasonable. Joining on src.process.cmdline is a performance trap — the field is high-cardinality, and joins on arbitrary string equality across millions of events are expensive.
count_distinct() is approximate above 10,000 unique values. For compliance reporting where the number has to be exact, use it on small distinct sets. For rough cardinality estimation on large datasets, use estimate_distinct(). The documentation does not always make this distinction clear.
limit belongs after sort, not before. A limit 100 at the top of an unfiltered pipeline limits input before your analysis runs. Every aggregation after it operates on 100 rows, not the population. The result is meaningless.
Test with limit 10. When building a new query, put | limit 10 at the end so execution is fast. Remove it or raise it when the logic is correct and you want production results.
Debugging Empty Results
Your query returns nothing. Either it is correct (nothing matches) or it is broken (the query never reaches real data). How to tell the difference:
Step 1: Strip all filters. Start with just the event category and limit 10.
event.category = "process"
| limit 10
If this returns nothing, the data stream is empty for your time window. Extend the time window. If it still returns nothing, the data pipeline may have a gap — contact your SentinelOne admin.
Step 2: Add one filter at a time. Once you have 10 rows from the bare stream, re-add your filters one line at a time. The filter that drops the result from 10 rows to 0 is the problem.
Step 3: Check field names. Field names in PowerQuery are case-sensitive at the schema level. src.process.Name does not match src.process.name. Use the SentinelOne Data Dictionary in your console to confirm exact field names for your platform version.
Step 4: Check null handling. A filter like src.process.parent.name = "cmd.exe" silently drops all rows where src.process.parent.name is null — which can be a significant portion of process events depending on agent configuration and OS version. Add src.process.parent.name != null explicitly, or use a ternary fallback for fields you know can be null.
Step 5: Check the time window. The default time window in the console is often shorter than you expect — 24 hours or less depending on query type. Events that occur weekly will not appear in a 24-hour window. Extend it before concluding the behavior does not exist in your environment.
Step 6: Check regex syntax. PowerQuery uses RE2 syntax, not PCRE. Named capture groups and lookaheads available in PCRE do not exist in RE2. A regex that works in a Python or grep context may silently produce empty results in PowerQuery. Test each pattern against a representative string before building a full query around it.
Debugging Noisy Results
Your query fires on everything and returns 50,000 rows of legitimate activity. How to find the signal.
Sort ascending on hit count. The rare events float to the top. The frequent, expected events sink to the bottom. Sort descending only when you specifically want to see the highest-volume activity, which is typically not what you want for a threat detection.
Add count_distinct(endpoint.name). A hit count of 10,000 spread across 500 endpoints is a different problem from 10,000 hits on 1 endpoint. The first is either widespread malware or a misfiring detection across your fleet. The second is one machine doing something. Know which you are looking at before deciding how to respond.
Group more aggressively. If results are noisy, add more fields to the group by. More dimensions per group row means more specific results, which makes noise identifiable as specific command lines, paths, or users rather than an undifferentiated mass of events.
Find your noise source first. sort hits desc | limit 20 on a grouped result shows the twenty most common patterns. If they are all signed Microsoft processes from System32, add path-based exclusions. If one specific cmdline makes up 80% of the hits, add an exclusion for that cmdline with a documented reason.
Use a scoring model. Instead of binary include/exclude, score each event by how many risk signals it presents. A PowerShell running from System32 with a recognizable parent gets a score of 0. The same binary running from %TEMP% with cmd.exe as parent and an encoded command scores 3 or 4. Set a threshold, tune the threshold, not individual exclusions.
Behavior to PowerQuery: A Mental Translation
When you observe a behavior during an investigation or read it in a threat report, the translation to PowerQuery follows a consistent pattern. Map the behavior to the stream, identify the key fields, validate them, build the filter.
| Attacker behavior | Event stream | Key filter approach |
|---|---|---|
| Process executed from temp or writable path | process | src.process.image.path matches:anycase regex covering temp, appdata, public paths |
| Network connection to external IP | ip | !net_private(dst.ip.address) and geo_ip_country() for country filter |
| DNS resolution of suspicious domain | dns | event.dns.request matches "pattern" |
| Registry persistence key written | registry | registry.keyPath contains "Run" or registry.keyPath contains "Schedule" |
| DLL loaded from non-standard path | module | module.path matches:anycase regex covering temp and appdata paths |
| Scheduled task created | registry | registry.keyPath contains "TaskCache" |
| Login failure followed by success | login join | event.login.result = "FAILED" joined to "SUCCESS" on endpoint and username |
| LSASS memory access | process | tgt.process.name = "lsass.exe" and event.type = "Open" |
| ETW or event log disabled | process | src.process.cmdline contains:anycase "wevtutil" or "logman" with disable flags |
| File dropped to disk | file | event.type = "WRITE" and file.path matches:anycase temp or public path regex |
| Named pipe created | cross_process | named_pipe.name matches "pattern" |
| Service installed | registry | registry.keyPath contains "CurrentControlSet\\Services" |
| Browser credential theft | process | src.process.cmdline contains "--remote-debugging-port" |
Start from the behavior. Map to the stream. Validate the fields in your environment before writing the full detection. The mapping is mechanical. The hard part is knowing which behaviors matter in your environment and which ones your current telemetry coverage actually captures.
Query Review Checklist
Before shipping a detection to production:
Field validation: Ran a sample query confirming all fields return values
Null handling: Fields that can be null are excluded or handled with ternary fallback
Output context: Result columns include enough for an analyst to act without a second query
Exclusions: Every exclusion has a comment with what it covers and when it was added
Sort and limit: limit is after sort, at the end of the pipeline
Time window: Appropriate for the detection type - rare behaviors need longer windows
Join validated: If joining, the join key is consistent and tested against both streams
FP rate tested: Ran against a known-good time window to measure baseline noise
Regex verified: All regex patterns tested against representative strings from live data
Named clearly: Query name and description in the console make the purpose obvious
The false positive test is the one most teams skip. Run the detection against a quiet period — a weekend, a holiday, a period with no known incidents. Count the hits. If it fires 200 times in a quiet period, it fires 2000 times during normal business hours. Fix it before it goes live. A detection that pages the analyst for every false positive trains the analyst to ignore pages.
Building a Personal Query Library
PowerQuery detections are reusable assets. A library of tested, tuned queries is worth more than running the same Google search every time an incident starts.
Track these fields for each query:
Name: [descriptive - not "test query 47" or "new version 3"]
ATT&CK Tactic: [TA0003 Persistence, TA0006 Credential Access, etc.]
ATT&CK Technique: [T1059.001 PowerShell, T1003.001 LSASS Memory, etc.]
Event streams: [process, registry, ip, login, module, file, dns, url]
Noise level: [low / medium / high - measured, not estimated]
Last validated: [date - when you last ran it against live data]
Purpose: [hunt / detection / investigation / baseline]
Exclusions: [what is excluded and why, with dates]
Notes: [schema version sensitivities, environment-specific caveats]
Organize by tactic, not by technique or tool. If you organize by technique, you end up with 200 folders. If you organize by tactic — Execution, Persistence, Privilege Escalation, Defense Evasion, Discovery, Lateral Movement, Collection, C2, Exfiltration, Impact — you get ten folders that cover everything and are fast to navigate during an active incident.
Validate quarterly. SentinelOne updates its schema between platform versions. Fields get added, renamed, or deprecated. A query that worked on version N-1 may return empty results on version N because a field name changed. Add a calendar reminder to run every library query against live data once per quarter and verify you still get results.
Document what your queries do not cover. Every detection has a gap. If your PowerShell detection excludes encoded commands exceeding a certain length because they were too noisy, note that. If a threat actor uses exactly that technique, you want to know which detection does and does not cover it. A library with documented gaps is more valuable than one that claims to cover everything.
Share tuned queries, not raw ones. If you post a query to a community or internal wiki without documenting your exclusions and the false positive rate you observed, the next person to run it will have a bad time. The raw query is not the deliverable. The documented, tuned, validated version is.
Final Word
Most organizations running SentinelOne are paying for a detection engineering platform and using it as an alert dashboard. The platform can do considerably more than acknowledge threats. The PowerQuery engine is the interface to that capability.
The queries in this post are starting points, not finished products. Every environment has different telemetry gaps, different schema versions, different noise sources. The field validation step is not optional. The staged build workflow is not optional. The false-positive tuning based on actual evidence, not guesswork, is not optional.
Write detections that answer the analyst's next question before they ask it. If you detect suspicious registry persistence, the result should show endpoint, user, parent, process, command line, registry key, registry value, first seen, last seen, and hit count. If the analyst has to open a separate query to get that context, the detection is incomplete.
Validate your fields. Test your output. Stop trusting the dashboard.
Jai Hind.
#SentinelOne #EDR #detection-engineering #cyber security #threat hunting #PowerQuery #Windows Security #hacking #research
🔑 Verify authenticity
PGP key xer0x-public.asc · id e8270d03
sha256(post) 154775ad0692df14a07956d944cfa564217e0e8f3bfc0633be90fe003c6e60d7
Confirm this post is byte-for-byte authentic — paste into any macOS or Linux terminal:
curl -fsSL https://xer0x.in/blog/s1-pq/content.txt | openssl dgst -sha256 | grep -qi 154775ad0692df14a07956d944cfa564217e0e8f3bfc0633be90fe003c6e60d7 && echo "signature ok" || echo "TAMPERED"