Query Details
id: a1b2c3d4-0004-4a5b-8c9d-dns004dga
name: DGA — High-Entropy Subdomain Pattern (Domain Generation Algorithm)
description: |
Detects clients communicating with Domain Generation Algorithm (DGA) generated
domains. DGA malware (Emotet, QakBot, Dridex, TrickBot, SolarWinds Sunburst)
generates pseudo-random domain names at regular intervals, trying many until
one resolves to an active C2 server.
Detection is based on the second-level domain character analysis:
- High ratio of consonants (>65%) — real words are ~40-55% consonant
- Contains embedded digits — rare in real brand names
- Length between 10–40 characters — DGA sweet spot
- High unique character count — randomness indicator
Differentiation from built-in "Potential DGA via Repetitive Failures
(Normalized DNS)":
The built-in detects DGA via NXDOMAIN failure rate only — if the C2 domain
has already been registered and resolves, the built-in misses it. This rule
applies consonant-ratio entropy analysis to SUCCESSFUL queries (NOERROR),
catching active C2 beaconing where the DGA domain resolved. Enables detection
of DGA malware in its post-initial-C2-registration phase.
severity: High
requiredDataConnectors:
- connectorId: WindowsDnsAma
dataTypes:
- ASimDnsActivityLogs
queryFrequency: 1h
queryPeriod: 1h
triggerOperator: gt
triggerThreshold: 0
status: Available
tactics:
- CommandAndControl
relevantTechniques:
- T1568.002
tags:
- DGA
- Emotet
- QakBot
- Dridex
- TrickBot
- Domain Generation Algorithm
query: |
ASimDnsActivityLogs
| where TimeGenerated > ago(1h)
| extend SLD = tostring(split(DnsQuery, ".")[-2])
| where strlen(SLD) between (10 .. 40)
| extend
SLDLen = strlen(SLD),
HasDigits = SLD matches regex @"\d",
ConsonantCount = countof(SLD, "b") + countof(SLD, "c") + countof(SLD, "d")
+ countof(SLD, "f") + countof(SLD, "g") + countof(SLD, "h")
+ countof(SLD, "j") + countof(SLD, "k") + countof(SLD, "l")
+ countof(SLD, "m") + countof(SLD, "n") + countof(SLD, "p")
+ countof(SLD, "q") + countof(SLD, "r") + countof(SLD, "s")
+ countof(SLD, "t") + countof(SLD, "v") + countof(SLD, "w")
+ countof(SLD, "x") + countof(SLD, "y") + countof(SLD, "z")
| extend ConsonantRatio = todouble(ConsonantCount) / todouble(SLDLen)
| where ConsonantRatio > 0.65
and HasDigits == true
| summarize
DgaLikeDomains = dcount(DnsQuery),
QueryCount = count(),
SampleDomains = make_set(DnsQuery, 15),
FirstSeen = min(TimeGenerated),
LastSeen = max(TimeGenerated)
by SrcIpAddr, SrcHostname
| where DgaLikeDomains > 10
entityMappings:
- entityType: Host
fieldMappings:
- identifier: HostName
columnName: SrcHostname
- entityType: IP
fieldMappings:
- identifier: Address
columnName: SrcIpAddr
alertDetailsOverride:
alertDisplayNameFormat: "DGA Activity — {{SrcHostname}} queried {{DgaLikeDomains}} high-entropy domains"
alertDescriptionFormat: "{{SrcHostname}} ({{SrcIpAddr}}) queried {{DgaLikeDomains}} high-entropy domains consistent with DGA malware activity. Sample: {{SampleDomains}}"
customDetails:
DgaLikeDomains: DgaLikeDomains
SampleDomains: SampleDomains
This query is designed to detect suspicious network activity that might indicate the presence of malware using Domain Generation Algorithms (DGA). DGAs are used by malware to generate a large number of domain names in hopes of connecting to a command and control (C2) server. Here's a simple breakdown of what the query does:
Data Source: It analyzes DNS activity logs from Windows DNS systems.
Time Frame: It looks at DNS queries made in the last hour.
Domain Analysis:
Detection Criteria:
Output:
Alerting:
This query helps identify potential malware activity by detecting patterns typical of DGA-generated domains, even if the domains successfully resolve, which might be missed by other detection methods focusing only on failed queries.

David Alonso
Released: March 26, 2026
Tables
Keywords
Operators