T1584.005 Microsoft Sentinel · KQL

Detect Botnet in Microsoft Sentinel

Adversaries may compromise numerous third-party systems to form a botnet that can be used during targeting. A botnet is a network of compromised systems that can be instructed to perform coordinated tasks. Instead of purchasing/renting a botnet from a booter/stresser service, adversaries may build their own botnet by compromising numerous third-party systems. Adversaries may also conduct a takeover of an existing botnet by redirecting bots to adversary-controlled C2 servers. With a botnet at their disposal, adversaries may perform follow-on activity such as large-scale phishing or Distributed Denial of Service (DDoS). Notable real-world operators include Volt Typhoon operating KV Botnet through compromised Cisco and NETGEAR SOHO routers, Sandworm's Cyclops Blink targeting SOHO network devices, HAFNIUM using compromised devices in covert proxy networks, and Axiom using large groups of compromised machines as proxy nodes.

MITRE ATT&CK

Tactic
Resource Development
Technique
T1584 Compromise Infrastructure
Sub-technique
T1584.005 Botnet
Canonical reference
https://attack.mitre.org/techniques/T1584/005/

KQL Detection Query

Microsoft Sentinel (KQL)
kusto
// Detect systems exhibiting botnet node behavior: beaconing to external IPs with
// regular intervals, IRC C2 port usage, or high-frequency outbound connections
// suggesting DDoS participation or automated bot check-ins.
let LookbackPeriod = 24h;
let MinConnectionsThreshold = 20;
let MinHourlyBuckets = 3;
let BotnetC2Ports = dynamic([6667, 6697, 6660, 6661, 6662, 6663, 6664, 6665, 6666, 6668, 6669, 1080, 4444]);
let PrivateRanges = dynamic(["10.", "172.16.", "172.17.", "172.18.", "172.19.", "172.20.",
  "172.21.", "172.22.", "172.23.", "172.24.", "172.25.", "172.26.", "172.27.", "172.28.",
  "172.29.", "172.30.", "172.31.", "192.168.", "127.", "169.254."]);
DeviceNetworkEvents
| where Timestamp > ago(LookbackPeriod)
| where ActionType in ("ConnectionSuccess", "ConnectionAttempt")
| where RemoteIPType == "Public"
| where not(RemoteIP has_any (PrivateRanges))
// Aggregate per device + remote endpoint to identify repeated connections over time
| summarize
    TotalConnections = count(),
    HourlyBuckets = dcount(bin(Timestamp, 1h)),
    BytesSent = sum(SentBytes),
    BytesReceived = sum(ReceivedBytes),
    FirstSeen = min(Timestamp),
    LastSeen = max(Timestamp),
    Processes = make_set(InitiatingProcessFileName, 10),
    ProcessPaths = make_set(InitiatingProcessFolderPath, 5)
    by DeviceName, AccountName, RemoteIP, RemotePort
| where TotalConnections >= MinConnectionsThreshold
| where HourlyBuckets >= MinHourlyBuckets
| extend
    AvgConnectionsPerHour = round(todouble(TotalConnections) / HourlyBuckets, 1),
    AvgBytesPerConnection = round(todouble(BytesSent + BytesReceived) / TotalConnections, 0),
    DurationHours = datetime_diff('hour', LastSeen, FirstSeen),
    IRCPort = RemotePort in (BotnetC2Ports)
// Score: IRC port use = 3, low-byte high-freq beaconing = 2, high-volume connections = 1
| extend BeaconingScore = case(
    IRCPort == true, 3,
    AvgBytesPerConnection < 500 and AvgConnectionsPerHour > 10, 2,
    TotalConnections > 200 and HourlyBuckets >= 6, 2,
    TotalConnections > 100, 1,
    0
)
| where BeaconingScore >= 1
| project
    FirstSeen, LastSeen, DeviceName, AccountName,
    RemoteIP, RemotePort, IRCPort,
    TotalConnections, HourlyBuckets, AvgConnectionsPerHour,
    AvgBytesPerConnection, BytesSent, BytesReceived,
    DurationHours, BeaconingScore, Processes, ProcessPaths
| sort by BeaconingScore desc, TotalConnections desc
high severity medium confidence

Detects systems potentially enrolled as botnet nodes by identifying network communication patterns consistent with C2 beaconing: high-frequency outbound connections to the same external IP sustained across multiple hours, IRC C2 port usage (6667, 6697, and variants), and low-bytes-per-connection patterns typical of automated bot heartbeats. Uses DeviceNetworkEvents to aggregate connection counts by device/destination over 24 hours, then scores results against multiple botnet behavioral indicators. This pivots from the unobservable adversary action (building the botnet by compromising third-party systems) to observable victim-side telemetry indicating your systems have been compromised and enrolled.

Data Sources

Network Traffic: Network Connection CreationNetwork Traffic: Network Traffic FlowMicrosoft Defender for Endpoint

Required Tables

DeviceNetworkEvents

False Positives & Tuning

  • Monitoring and observability agents (Datadog, SolarWinds, PRTG, Zabbix) that check-in to cloud endpoints at regular intervals with small payloads
  • Software update services and telemetry clients (Windows Update, browser update checks, antivirus cloud lookups) that connect frequently to the same CDN or update endpoint
  • VoIP and real-time communication platforms that maintain persistent connections with high-frequency keepalives
  • Gaming clients, streaming services, and P2P applications that maintain persistent external connections
  • Network management tools or custom scripts that perform frequent health checks against external services
Download portable Sigma rule (.yml)

Other platforms for T1584.005


Testing Methodology

Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.

  1. Test 1Simulate Botnet Beaconing via PowerShell Loop

    Expected signal: Sysmon Event ID 1: Process Create with Image=powershell.exe, CommandLine containing 'DownloadString' and a loop. Sysmon Event ID 3: 30 network connection attempts to 127.0.0.1:8080 over approximately 2.5 minutes. In DeviceNetworkEvents: ConnectionCount will accumulate for the powershell.exe process against the target IP. The connection will fail (no listener) but the attempt events still fire.

  2. Test 2IRC C2 Port Connection Attempt

    Expected signal: Sysmon Event ID 3: Network connection attempt from powershell.exe to 127.0.0.1:6667. DestinationPort=6667 will be logged regardless of whether the connection succeeds. In DeviceNetworkEvents: ActionType will be 'ConnectionAttempt' or 'ConnectionFailed' with RemotePort=6667.

  3. Test 3High-Frequency Outbound Connection Burst (DDoS Simulation)

    Expected signal: Sysmon Event ID 3: 150 network connection events from powershell.exe in rapid succession, each to 127.0.0.1 on different ports. The ConnectionCount in a 15-minute window will exceed 100, triggering the DDoS burst hunting query. UniquePorts will be high (random port selection), triggering ScanIndicator evaluation.

  4. Test 4DNS Query Burst to Simulated DGA Domains

    Expected signal: Sysmon Event ID 22: 60 DNS query events from powershell.exe, each for a unique random-looking domain name. The vast majority will return NXDOMAIN (non-existent domain). DNS debug log (if enabled) will show the same pattern. DnsQueryResults field will contain NXDOMAIN indicators for each failed lookup.

Unlock Pro Content

Get the full detection package for T1584.005 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections