Query Details
# Matching IP redirectors from UrlClickEvents table with URLHaus external threat intel source
## Description
The following query leverages UrlClickEvents and more specifically the UrlChain column to unfold redirectors identified from user's clicks at Emails, Teams messages and Office 365 apps, and also matches these redirector URLs to OpenPhish theat intelligence source.
### Microsoft Defender XDR
```
let URLHausOnlineRAW = externaldata (UHFeed:string) ["https://urlhaus.abuse.ch/downloads/csv_online/"] with(format="txt")
| where UHFeed !startswith "#"
| extend UHRAW=replace_string(UHFeed, '"', '')
| project splitted=split(UHRAW, ',')
| mv-expand id=splitted[0], dateadded=splitted[1], UHUrl=splitted[2], UHurl_status=splitted[3], UHlast_onlin=splitted[4], UHthreat=splitted[5], UHtags=splitted[6], UHLink=splitted[7], UHReporter=splitted[8]
| extend UHUrl = tostring(UHUrl)
| extend UHExtractedIP = extract(@'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', 0, UHUrl)
| where isnotempty(UHExtractedIP);
UrlClickEvents
| where ActionType == "ClickAllowed" // Click has been allowed by SafeLinks
| extend UrlChain = todynamic(UrlChain)
| mv-expand UrlChain
| extend UrlString = tostring(UrlChain)
| extend ExtractedIP = extract(@'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})', 0, UrlString)
| where isnotempty(ExtractedIP)
| join kind=inner URLHausOnlineRAW on $left.ExtractedIP == $right.UHExtractedIP
```
### Versioning
| Version | Date | Comments |
| ------------- |---------------| ---------------------------------------|
| 1.0 | 18/3/2025 | Initial publish |
This query is designed to identify potentially malicious URL redirectors by analyzing user click events and comparing them against a known threat intelligence source, URLHaus. Here's a simplified breakdown of what the query does:
Fetch External Threat Data:
Process URLHaus Data:
Analyze User Click Events:
UrlClickEvents table, specifically focusing on events where clicks were allowed by SafeLinks (a security feature).Extract and Match IP Addresses:
UrlChain column in the UrlClickEvents table, which records the sequence of URLs a user was redirected through, the query extracts IP addresses.Identify Malicious Redirectors:
Overall, this query helps in identifying and analyzing potentially harmful URL redirectors that users encounter through emails, Teams messages, and Office 365 apps by leveraging external threat intelligence data.

Michalis Michalos
Released: March 18, 2025
Tables
Keywords
Operators