The short answer#
You need two things. The first is a record of the domains each device resolved or connected to. The second is a list of domains you consider malicious. Endpoint telemetry or DNS resolver logs give you the first. Threat intelligence, lookalikes of your own domains, and your own block events give you the second. Matching the two shows which devices reached which bad domains, and when.
Where the data lives#
| Source | What it records | Things to know |
|---|---|---|
| Microsoft Defender for Endpoint, advanced hunting | Connections in DeviceNetworkEvents, with RemoteUrl, RemoteIP, DeviceName, and the process that connected. Network protection blocks and SmartScreen warnings in DeviceEvents | Needs Plan 2 or Microsoft Defender XDR. Keeps 30 days by default. Some licenses extend supported tables to 90 days |
| Protective DNS or your own resolver | Every name a device looked up, and whether the resolver blocked it | Misses devices that use another resolver, such as a browser with DNS over HTTPS |
| Sysmon on Windows endpoints | Event ID 22 for each DNS query a process makes, cached or not | You collect and store the events yourself, usually in a SIEM |
| Secure web gateway or firewall | Hostnames from proxy logs or the TLS handshake | Covers only traffic that passes through it |
Microsoft documents the advanced hunting retention in its advanced hunting overview, and the Sysmon event in the Sysmon reference.
Query advanced hunting#
Start from the domains you already suspect. This query lists every device that connected to them in the last 30 days:
let suspicious = dynamic(["examp1e-login.com", "example-support.net"]);
DeviceNetworkEvents
| where Timestamp > ago(30d)
| where ActionType == "ConnectionSuccess"
| where RemoteUrl has_any (suspicious)
| summarize Connections = count(), FirstSeen = min(Timestamp), LastSeen = max(Timestamp)
by DeviceName, RemoteUrl, InitiatingProcessFileName
| order by LastSeen descThen check what your controls stopped. A block means someone, or something, tried:
DeviceEvents
| where Timestamp > ago(30d)
| where ActionType in ("ExploitGuardNetworkProtectionBlocked", "SmartScreenUrlWarning")
| where isnotempty(RemoteUrl)
| summarize Blocks = count(), Devices = dcount(DeviceName) by RemoteUrl
| order by Blocks descTo find domains you did not know to look for, compare recent destinations with a baseline. A domain that many devices reached for the first time today, and never in the month before, deserves a look. So does any destination that resembles your own domain with a small change, such as examp1e.com for example.com. Lookalike domains explains the patterns.
Domain protection
Detect adversary infrastructure while it is being staged.
Have I Been Squatted helps security teams detect lookalike domains, certificate and DNS changes, and staging infrastructure, investigate the evidence, and coordinate takedowns.
What the logs miss#
- Defender does not log every connection. In testing, connections made by some processes, such as PowerShell, were missing from advanced hunting.
- A block can still show as a connection. Defender decides after the connection opens, so
DeviceNetworkEventscan recordConnectionSuccessfor a site network protection then blocked. Read the block events alongside it. - Unmanaged devices are invisible. Personal phones and contractor laptops appear in neither endpoint telemetry nor, off your network, in resolver logs.
- A connection is not a compromise. Email link scanners, browsers that load links ahead of time, and security tools also reach malicious domains. Check the process and the user before you escalate.
Decide what counts as malicious#
Matching is only as good as the list you match against. Combine:
- Threat intelligence you can explain to the person whose device you are about to investigate.
- Lookalikes of your own domains, found by domain monitoring in new registrations and certificate transparency logs. These are the domains most likely aimed at your staff and customers.
- Newly seen destinations, which catch infrastructure that no feed lists yet.
- Your own block events, which show attempts your controls already stopped.
When a device reached a domain that turns out to be malicious, block it everywhere, then find out how the device got there, such as an email, a search ad, or a link in chat. How to block phishing domains in Microsoft Defender for Endpoint covers the block.
How Have I Been Squatted does it#
Have I Been Squatted Network Intelligence, an Enterprise add-on, runs this matching continuously.
- Sources. It reads Defender for Endpoint through read-only advanced hunting queries every 15 seconds, or Cloudflare Gateway DNS analytics every minute.
- What it keeps. Counts per destination per hour, with a sample of hosts and addresses, for 90 days. It does not store device names, user names, internal addresses, or full URLs, so you return to Defender to see which device connected.
- What it shows. New destinations in the past 24 hours that were not reached in the 30 days before, the most reached destinations, and the most blocked.
- What it does. Network rules raise an alert and notify Slack, a SIEM or a webhook. Blocks and Takedowns act on lookalike domain records, so they come from rules with a domain condition, or from domains your team sends to a control by hand.
The Network Intelligence guide covers setup, and Network Intelligence describes the add-on.
Frequently asked questions#
Do DNS logs show that a device reached a malicious site?#
DNS logs show that a device looked up a domain. A lookup can happen before a browser opens a page, and the resolver may block it. Check endpoint or gateway logs to see whether a connection followed.
Why does Defender show a successful connection to a blocked domain?#
Defender can record a connection before network protection decides to block it. Check the matching events in DeviceEvents alongside DeviceNetworkEvents to see whether Defender blocked the attempt.
How do I find malicious domains that are missing from my blocklist?#
Compare recent destinations with the domains your devices normally reach. Investigate newly seen destinations that resemble domains your staff use, and check the initiating process, DNS records, and reputation before escalating.