Tools / Guides / IOC hunting queries

How to hunt for IOCs in Sentinel, Defender and Splunk

Practical KQL and SPL for hunting IP addresses, domains, URLs and file hashes from a threat report across Microsoft Sentinel, Defender XDR and Splunk, which tables to search, and how to handle long indicator lists.

Updated 2026-11-07 · 8 min read

A threat report lands with forty indicators: a handful of C2 IPs, some domains, a few SHA-256 hashes. Someone asks the obvious question: have we seen any of these? Answering it well means searching the right tables for each type of indicator, over a sensible time window, without writing forty separate queries.

This guide covers how to hunt for IOCs in Microsoft Sentinel, Defender XDR and Splunk: where each indicator type shows up, the query patterns that scale, and the mistakes that produce false confidence.

Which tables should I search for each indicator type?

IndicatorDefender XDR / SentinelSplunk (CIM)
IP addressDeviceNetworkEvents (RemoteIP), CommonSecurityLog (firewalls), SigninLogs (IPAddress)Network_Traffic data model, src_ip / dest_ip
DomainDeviceNetworkEvents (RemoteUrl), DeviceEvents DNS queries, EmailUrlInfo, UrlClickEvents, DnsEventsNetwork_Resolution (query), Web (url)
File hashDeviceFileEvents, DeviceProcessEvents, EmailAttachmentInfoEndpoint data model, file_hash
Email senderEmailEvents (SenderFromAddress)Email data model, src_user

The most common gap is DNS. A blocked connection may never appear in network logs, but the DNS lookup that preceded it usually does. Always search DNS for domains.

What does a good KQL hunting query look like?

Put the indicators in a dynamic array once and search several tables with union. isfuzzy=true means a table your workspace doesn't have is skipped instead of failing the whole query:

let lookback = 30d;
let ips = dynamic(["185.220.101.45", "45.137.21.9"]);
union isfuzzy=true
  (DeviceNetworkEvents | where Timestamp > ago(lookback) | where RemoteIP in (ips)
     | project Timestamp, Source="DeviceNetworkEvents", DeviceName, Indicator=RemoteIP, InitiatingProcessFileName),
  (SigninLogs | where TimeGenerated > ago(lookback) | where IPAddress in (ips)
     | project Timestamp=TimeGenerated, Source="SigninLogs", UserPrincipalName, Indicator=IPAddress, ResultType)
| sort by Timestamp desc

For domains, use has_any rather than ==, so update-cdn-sync.xyz also matches cdn.update-cdn-sync.xyz and full URLs. For hashes, check SHA-256, SHA-1 and MD5 columns; reports mix them, and Defender records all three.

And in Splunk?

A raw search works anywhere, but name the fields so you don't match a hash that happens to appear in an unrelated log line:

index=* earliest=-30d (src_ip IN ("185.220.101.45","45.137.21.9") OR dest_ip IN ("185.220.101.45","45.137.21.9"))
| stats count min(_time) as first_seen max(_time) as last_seen by index, sourcetype, host

If your data is mapped to the CIM, tstats over the Network_Traffic data model is far faster on large environments. It only sees accelerated, CIM-tagged data, so when it returns nothing, confirm with a raw search before you report "not seen".

How far back should I look?

Match the window to the report. For an active campaign, 30 days is a reasonable default; for indicators from a long-running intrusion, go as far as your retention allows, often 90 days in Sentinel's analytics tier. Infrastructure gets reused, so an IP that hosted C2 last month may be benign today. A hit means "investigate", not "compromised".

What if the list has hundreds of indicators?

Large inline arrays make queries slow and hard to read. In Sentinel, load the list into a watchlist and join on it with _GetWatchlist('report-iocs'). In Splunk, use a lookup file with | inputlookup. Both let you reuse the same list for a scheduled detection after the hunt.

What are the usual mistakes?

Pulling the indicators out of a report cleanly is the first step; the defanging guide covers the formats you'll meet, and investigating a suspicious IP covers what to do with a hit.

FAQ

Why does my KQL query fail with "failed to resolve table"?

The table doesn't exist in that workspace, for example SigninLogs without the Entra ID connector. Use union isfuzzy=true so missing tables are skipped.

Should I use has or contains for domains?

Use has or has_any. They use the term index and are much faster than contains, and they match whole terms, which is what you want for domains.

Does Defender XDR advanced hunting keep data as long as Sentinel?

No. Advanced hunting keeps 30 days. For older data, query the same tables in Sentinel if you stream Defender data there.

Can I turn a hunting query into a detection?

Yes. Once the indicator list is in a watchlist or lookup, save the query as a scheduled analytics rule or saved search, with a shorter window such as one hour.