foyl Concepts / DNS Tunnelling
Attack Technique

DNS Tunnelling

DNS has to work for anything else to work, so it is almost never blocked - which makes it a perfect covert channel. Attackers smuggle stolen data and command-and-control traffic inside DNS queries themselves. Type a secret below, watch it get chunked into lookups, and see exactly which signals give it away.

T1071.004 DNS T1048 Exfiltration Over Alternative Protocol Interactive tunnelling lab
DNS tunnelling lab - encode a secret into queries, then read the detection signals
avg label length
-
avg label entropy (bits/char)
-
queries to one domain
-
Send some queries to see whether this looks like tunnelling.
How the channel works
The query itself carries the payload - resolution is just the delivery mechanism

Every DNS lookup for something.attacker.com eventually reaches the attacker's authoritative name server, because that is how recursive resolution works. The attacker owns attacker.com, so they receive the full query - including whatever they stuffed into the subdomain labels.

To exfiltrate, malware encodes the stolen data (hex or base32, since DNS names are restricted), splits it into chunks that fit in labels, and issues a lookup per chunk. To receive commands, it reads the answer records the attacker's server sends back. It is slow and chatty - but it flows straight through most egress controls, because blocking DNS breaks everything.

How defenders catch it

Tunnelling trades stealth of protocol for loudness of pattern. The same properties that carry data are the signals you hunt on, exactly the ones the lab above measures:

Label length & entropy: Real hostnames are short, pronounceable, and repeat (autodiscover, cdn). Encoded payloads are long and look random - high Shannon entropy. Alerting on labels over ~40 characters with high entropy catches most naive tunnels.

Volume & unique subdomains to one domain: A host making hundreds of lookups to a single second-level domain, each with a different high-entropy subdomain, is not normal browsing. That fan-out of unique names is the fingerprint.

Record types & domain reputation: Heavy use of TXT or NULL records (which carry more data) and queries to newly-registered or low-reputation domains raise the score further.

ToolWhat to hunt
NGFWDNS labels > 40 chars with high entropy; high unique-subdomain count per domain; heavy TXT/NULL usage
SIEMPer-host query volume to a single second-level domain over time; entropy scoring on qname
TIPReputation and age of the queried domain; known tunnelling toolmarks (iodine, dnscat2)
foyl SecIntel - the beacon next door
d3adbeef123456789.update.microsoft-cdn-verify.net

The IRON CHIMNEY C2 domain is a close cousin of a DNS tunnel: a long, high-entropy label on a lookalike apex, queried on a timer from RESEARCH-STATION-01. Whether an attacker is beaconing or bulk-exfiltrating, the DNS tells on them the same way - unusual label shape, volume to one domain, and a freshly registered lookalike.

That is why the DNS resolver on SI-DC-01 is one of the richest hunting grounds in the environment. Combine label-shape scoring with domain reputation and you catch both the slow tunnel and the periodic beacon.

Related concepts