KQL of the Week: Hunting Exposed Offensive AI Infrastructure with KQL Queries
AI-powered offensive security frameworks are no longer limited to isolated research environments. Some expose web consoles and APIs directly to the public Internet. But how many of these instances are visible online and are any of our systems communicating with them? offensive.agency provides an interesting starting point.
Using Internet scanning data from ONYPHE, the project tracks publicly exposed web consoles and APIs associated with autonomous offensive security agents. The tracker uses several fingerprint families to identify probable or confirmed deployments, including web pages, favicons and certificates. It also provides historical observations, domain information and infrastructure context.
One important distinction: an exposed offensive AI agent is not automatically malicious infrastructure. Researchers, penetration testers, students and malicious actors may all operate these tools.
The objective of this hunting exercise is to discover potentially interesting interactions that deserve further investigation.
From public threat intelligence to Defender XDR
The project provides several public exports:
- https://offensive.agency/api/ips.txt
- https://offensive.agency/api/domains.txt
- https://offensive.agency/api/hosts.csv
- https://offensive.agency/api/hosts.json
It also supports filters such as scope=all, c2=1, country, level, kind and tool. The interesting part is that Microsoft Defender XDR supports the KQL externaldata() operator. This means we can query the public feeds directly, without manually downloading IP lists or maintaining static indicators. Let’s turn that data into several hunting scenarios.
Hunt 1 — Outbound interactions to exposed offensive AI infrastructure
Firstly, I am identifying endpoints establishing connections to IP addresses included in the tracker.
DeviceNetworkEvents XDR Table
let OffensiveIPs = externaldata(IP:string) [@"https://offensive.agency/api/ips.txt"] with (format="txt")
| where isnotempty(IP) and not(IP startswith "#")
| project IP=trim(@"\s+",IP); DeviceNetworkEvents
| where Timestamp > ago(7d)
| where ActionType == "ConnectionSuccess" | join kind=inner (OffensiveIPs) on $left.RemoteIP == $right.IP
URLClickEvents XDR Table
let OffensiveIPs = externaldata(IP:string) [@"https://offensive.agency/api/ips.txt"] with (format="txt") | where isnotempty(IP) and not(IP startswith "#") | project IP=trim(@"\s+",IP);
UrlClickEvents | join kind=inner (OffensiveIPs) on $left.IPAddress == $right.IP
This gives us visibility into which devices contacted infrastructure associated with exposed offensive AI agents.
However, an IP match alone is not evidence of malicious activity. Shared hosting and cloud infrastructure can introduce false positives such as CloudFare connections.
Hunt 2 — Connections to offensive AI domains
IP addresses are not always reliable indicators, particularly when infrastructure is hosted behind CDNs. The tracker also provides a domain export, allowing us to search for connections using the destination hostname.
DeviceNetworkEvents XDR Table
let OffensiveDomains = externaldata(Domain:string) [@"https://offensive.agency/api/domains.txt"] with (format="txt") | where isnotempty(Domain) and not(Domain startswith "#")
| project Domain=tolower(trim(@"\s+",Domain));
DeviceNetworkEvents | where Timestamp > ago(7d) | where isnotempty(RemoteUrl) | extend Host=tolower(tostring(split(tostring(split(RemoteUrl,"://")[-1]),"/")[0]))
| extend Host=tostring(split(Host,":")[0])
| join kind=inner (OffensiveDomains) on $left.Host == $right.Domain
URLClickEvents XDR Table
let OffensiveDomains = externaldata(Domain:string) [@"https://offensive.agency/api/domains.txt"] with (format="txt") | where isnotempty(Domain) and not(Domain startswith "#")
| project Domain=tolower(trim(@"\s+",Domain));
UrlClickEvents | where Timestamp > ago(7d) | where isnotempty(Url) | extend Host=tolower(tostring(split(tostring(split(Url,"://")[-1]),"/")[0]))
| extend Host=tostring(split(Host,":")[0])
| join kind=inner (OffensiveDomains) on $left.Host == $right.Domain
This is particularly useful for identifying interactions with exposed web consoles where multiple unrelated services share the same public IP. It searches network destination hostnames rather than relying on DNS events being available.
Hunt 3 — Inbound connections from tracked infrastructure
What happens when infrastructure included in the tracker initiates connections toward our monitored endpoints? This hunting scenario looks for inbound network activity associated with the published IP addresses.
DeviceNetworkEvents XDR Table
let OffensiveIPs = externaldata(IP:string) [@"https://offensive.agency/api/ips.txt"] with (format="txt") | where isnotempty(IP) and not(IP startswith "#") | project IP=trim(@"\s+",IP); DeviceNetworkEvents | where Timestamp > ago(7d) | where ActionType startswith "Inbound" | join kind=inner (OffensiveIPs) on $left.RemoteIP == $right.IP | project Timestamp, DeviceName, LocalIP, LocalPort, RemoteIP, RemotePort, ActionType, InitiatingProcessFileName | order by Timestamp desc
🚨 Interesting findings include unexpected inbound connections to administrative services, repeated connection attempts or the same external IP communicating with multiple internal servers.
Hunt 4 — Infrastructure with C2 co-hosting indicators
One particularly interesting feature of offensive.agency is its ability to identify infrastructure where other services, including command-and-control frameworks, have also been observed. The API provides a c2=1 filter. We can use it to prioritize infrastructure that deserves closer inspection.
KQL — DeviceNetworkEvents XDR Table
let C2AssociatedIPs = externaldata(IP:string) [@"https://offensive.agency/api/ips.txt?c2=1"] with (format="txt")
| where isnotempty(IP) and not(IP startswith "#") | project IP=trim(@"\s+",IP);
DeviceNetworkEvents | where Timestamp > ago(7d) | join kind=inner (C2AssociatedIPs) on $left.RemoteIP == $right.IP
| summarize FirstSeen=min(Timestamp), LastSeen=max(Timestamp), Connections=count(), Processes=make_set(InitiatingProcessFileName,20), Ports=make_set(RemotePort,20), RemoteURLs=make_set(RemoteUrl,20), Actions=make_set(ActionType,10)
by DeviceName, RemoteIP
A match against C2-associated infrastructure deserves attention, but it does not mean that the observed connection used a C2 protocol. The same IP may host several unrelated services.
Some important limitations
The tracker is based on passive analysis of Internet scanning data. It does not actively interact with the identified hosts. It distinguishes active observations from historical records and warns about the limitations of shared infrastructure. The scope=all option includes historical observations, but an IP address observed in the past may now belong to another organization.
For that reason, historical IP matches should be evaluated against the observation dates in the source data. Also, externaldata() retrieves the external feed at query execution time. This is useful for interactive hunting, but it means the feed can change between investigations. For reproducible investigations, preserving the feed snapshot and collection time is valuable.
Final thoughts
Threat intelligence becomes much more valuable when we move beyond collecting indicators and start correlating them with actual endpoint behavior. The offensive.agency project provides an interesting dataset for exploring the growing exposure of offensive AI infrastructure.
With KQL, we can quickly investigate outbound connections, inbound activity, domain matches, suspicious processes and infrastructure associated with C2 services.
⚠️ Important: The goal is not to flag every listed IP as malicious. The goal is to understand why our devices are communicating with that infrastructure.
References
- offensive.agency — Methodology and Exports
- ONYPHE
- Microsoft Defender XDR — Advanced Hunting Best Practice
KQL of the Week: Hunting Exposed Offensive AI Infrastructure with KQL Queries was originally published in Detect FYI on Medium, where people are continuing the conversation by highlighting and responding to this story.
Generated by your browser's model. Nothing was sent anywhere.
Mentions (1)
- left[.]host Domain
Reader notes
Notes are held for moderation. No account needed.