Query Details
let PornBlockListProj = externaldata(type: string)[@"https://raw.githubusercontent.com/blocklistproject/Lists/master/porn.txt"] with (format="csv", ignoreFirstRecord=False) | where type !startswith "#" | extend RemoteUrl = replace_string(replace_string(type,"0.0.0.0", "")," ","") | project RemoteUrl; let PiracyBlockListProj= externaldata(type: string)[@"https://raw.githubusercontent.com/blocklistproject/Lists/master/piracy.txt"] with (format="csv", ignoreFirstRecord=False) | where type !startswith "#" | extend RemoteUrl = replace_string(replace_string(type,"0.0.0.0", "")," ","") | project RemoteUrl; let TorrentBlockListProj = externaldata(type: string)[@"https://raw.githubusercontent.com/blocklistproject/Lists/master/torrent.txt"] with (format="csv", ignoreFirstRecord=False) | where type !startswith "#" | extend RemoteUrl = replace_string(replace_string(type,"0.0.0.0", "")," ","") | project RemoteUrl; let PhishingBlockListProj = externaldata(type: string)[@"https://raw.githubusercontent.com/blocklistproject/Lists/master/phishing.txt"] with (format="csv", ignoreFirstRecord=False) | where type !startswith "#" | extend RemoteUrl = replace_string(replace_string(type,"0.0.0.0", "")," ","") | project RemoteUrl; let MalwareBlockListProj = externaldata(type: string)[@"https://raw.githubusercontent.com/blocklistproject/Lists/master/malware.txt"] with (format="csv", ignoreFirstRecord=False) | where type !startswith "#" | extend RemoteUrl = replace_string(replace_string(type,"0.0.0.0", "")," ","") | project RemoteUrl; let RansomBlockListProj = externaldata(type: string)[@"https://raw.githubusercontent.com/blocklistproject/Lists/master/ransomware.txt"] with (format="csv", ignoreFirstRecord=False) | where type !startswith "#" | extend RemoteUrl = replace_string(replace_string(type,"0.0.0.0", "")," ","") | project RemoteUrl; DeviceNetworkEvents | where RemoteUrl in~(PornBlockListProj) or RemoteUrl in~(TorrentBlockListProj) or RemoteUrl in~(PiracyBlockListProj) or RemoteUrl in~(PhishingBlockListProj) or RemoteUrl in~(MalwareBlockListProj) or RemoteUrl in~(RansomBlockListProj) |extend VT_domain = iff(isnotempty(RemoteUrl),strcat(@"https://www.virustotal.com/gui/domain/",RemoteUrl),RemoteUrl) | summarize count() by RemoteUrl,VT_domain
This KQL (Kusto Query Language) query is designed to identify and summarize network events related to potentially harmful or unwanted websites. Here's a simplified breakdown of what the query does:
Data Import and Cleaning:
Network Event Filtering:
DeviceNetworkEvents table to see if any recorded network events involve URLs that match any of the URLs in the blocklists.URL Enrichment:
Summarization:
In summary, this query is used to detect and count network events involving potentially harmful or unwanted URLs by cross-referencing them with known blocklists, and it provides additional context by linking to VirusTotal for each URL.

Jay Kerai
Released: February 4, 2025
Tables
Keywords
Operators