Adversaries may set up their own DNS servers for C2 channels, credential capture, and adversary-in-the-middle attacks during targeting operations.
DNS is the internet's phone book, trusted by nearly every network. When adversaries control DNS infrastructure, they gain an invisible command-and-control channel that bypasses most firewalls, since DNS traffic (port 53 UDP/TCP) is rarely blocked. Organizations that fail to monitor DNS traffic provide adversaries a covert tunnel into and out of their networks.
DNS was designed in 1983 with almost no security considerations. Adversaries exploit this trust by running their own authoritative DNS servers that respond only to malware queries while appearing completely legitimate to network defenders. DNS tunneling encodes data within query strings and TXT record responses, creating a bidirectional data channel that is extremely difficult to detect without specialized monitoring tools. The MITRE ATT&CK T1583.002 technique has been observed in advanced persistent threat (APT) operations worldwide.
According to cybersecurity research, DNS-based attacks account for a significant portion of command-and-control traffic in advanced intrusions. The CISA has issued multiple advisories on DNS hijacking campaigns targeting government and critical infrastructure organizations. The NIST Cybersecurity Framework emphasizes DNS monitoring as a critical detection capability.
By setting up their own DNS servers instead of hijacking existing ones, adversaries gain full administrative control over how they serve responses. This enables conditional C2 delivery (different responses for different malware variants), credential capture through DNS redirection, and flexible tunneling architecture that can be rapidly reconfigured if detected.
Acquire Infrastructure: DNS Server (T1583.002), The practice of setting up and configuring Domain Name System servers controlled by an adversary to support cyber operations. Unlike DNS hijacking, the adversary creates and operates entirely new DNS infrastructure, giving them full control over responses, logging, and conditional routing behavior. This enables covert command-and-control, data exfiltration, credential capture, and adversary-in-the-middle attacks.
📞 “Like setting up your own fake phone directory, when someone looks up a number, you can redirect them to wherever you want.” Imagine replacing your city's phone book with one you printed yourself. Anyone who looks up “Bank of America” gets your fake bank's number instead. You capture their account details when they call. Meanwhile, legitimate lookups for “Pizza Hut” still work normally, so nobody notices anything is wrong. That's exactly how adversary DNS servers operate: normal traffic passes through, but specific lookups are intercepted and weaponized.
A technique that encodes data within DNS queries and responses to create a covert communication channel. Data is typically encoded in subdomain labels (e.g., dGhpcyBpcyBzZWNyZXQ=.attacker.net) and extracted via TXT or CNAME record responses.
Using DNS TXT (text) records to deliver command-and-control instructions to malware. Since TXT records can contain arbitrary text data, adversaries embed base64-encoded commands that malware decodes and executes.
Redirecting DNS queries to adversary-controlled servers by modifying DNS resolver settings, cache poisoning, or exploiting delegation chains. Different from T1583.002 which involves setting up entirely new DNS infrastructure.
DNS server configuration that returns different responses based on the query source, query pattern, or encoded malware identifier. Enables targeted C2 delivery to specific compromised hosts while maintaining normal resolution for others.
An encryption protocol that wraps DNS queries in HTTPS, making it harder to monitor and detect DNS tunneling. Adversaries exploit DoH to further obfuscate their C2 traffic from network security tools.
“DNS is the perfect invisibility cloak. Every firewall lets it through. Every admin ignores it. You just need to build the right phone book.”
Alexei Morozov, a skilled infrastructure architect working for a sophisticated threat group, is tasked with building a DNS-based command-and-control infrastructure to support a long-term espionage campaign targeting government agencies across Eastern Europe and Central Asia. His approach is methodical: rather than hijacking existing DNS servers (which can be detected through DNS monitoring), he deploys entirely new DNS infrastructure under his control.
Alexei leases three Virtual Private Servers (VPS) in different countries using cryptocurrency payments. He installs BIND9 and Unbound DNS software, configuring them as authoritative nameservers for domains registered through privacy-protecting registrars. Each server is configured with conditional response rules that will serve as the backbone of the C2 network.
He configures his DNS servers with a dual-mode response system. For legitimate-looking queries, the servers return normal, valid responses to avoid suspicion. But for queries matching specific encoded patterns from malware implants (identified by unique subdomain prefixes), the servers return TXT records containing base64-encoded commands. This conditional logic ensures only infected hosts receive C2 instructions.
Alexei sets up a second DNS configuration for credential harvesting. When malware on a victim network resolves internal service hostnames, his DNS server returns IP addresses pointing to attacker-controlled servers that impersonate the organization's email portal, VPN gateway, and internal wiki. Employees who connect to these services unknowingly submit their credentials directly to the adversary's collection servers.
Compromised systems begin exfiltrating stolen documents by encoding file contents into DNS query subdomain labels. Alexei's DNS server logs all incoming queries, reassembles the encoded data chunks, and stores the exfiltrated files on a separate secured server. The entire data transfer occurs over port 53 UDP, bypassing all egress filtering. Each exfiltrated file appears as hundreds of seemingly normal DNS lookup failures in firewall logs.
Over 14 months, Alexei's DNS infrastructure supports the compromise of 23 government agencies across 6 countries. The tunneling channel transfers over 2.7TB of classified documents. Credential harvesting yields 4,800+ valid account credentials. The operation remains undetected for over a year because the adversary-controlled DNS servers blend seamlessly with normal DNS traffic patterns. Related techniques include T1583.001 Domains and T1583.003 Virtual Private Servers.
Eventually, a threat intelligence researcher notices an unusual pattern in passive DNS databases: a cluster of newly registered domains all pointing to the same small set of nameserver IPs across different hosting providers. Cross-referencing with DNS query logs from a compromised network reveals the encoded subdomain patterns, leading to full exposure of the adversary's DNS infrastructure. The domains and IPs are shared through ISACs, and defensive actions disrupt the entire campaign.
Educational Purpose Only: This guide illustrates the attack methodology for defensive understanding. Security professionals should use this knowledge to build detection rules, harden DNS infrastructure, and implement monitoring capabilities. Unauthorized deployment of adversarial DNS infrastructure is illegal.
Acquire and provision VPS or dedicated servers in multiple jurisdictions to create a resilient DNS infrastructure.
Set up the DNS server with custom zone files, response policies, and logging infrastructure.
Configure the DNS server to serve different responses based on query characteristics and source identification.
Build the command-and-control communication channel using DNS record types as the transport mechanism.
Conduct thorough testing of the DNS tunneling channel to ensure reliability, performance, and stealth.
Implement OPSEC measures to prevent detection and ensure long-term sustainability of the DNS infrastructure.
Related techniques for comprehensive infrastructure analysis:
Threat hunters should look for these indicators when investigating potential adversary-controlled DNS infrastructure within their environments. Each hypothesis includes specific detection queries that can be deployed in SIEM platforms.
Malware using DNS tunneling generates queries with abnormally long subdomain labels containing high-entropy encoded data. These queries often target domains not normally seen in the organization's traffic baseline.
Normal users rarely query TXT records directly. An unusual volume of TXT queries to the same domain or from the same source IP strongly indicates DNS-based C2 activity.
DNS tunneling uses base32 or base64 encoded data in subdomain labels, which produces significantly higher Shannon entropy than legitimate domain names. Thresholds above 3.5-4.0 bits per character warrant investigation.
DNS tunneling tools encode data in increasingly long query strings. Monitoring for sudden spikes in average query length from specific hosts can reveal active exfiltration attempts.
DNS tunneling generates many failed lookups as data is encoded in unique subdomains. A sudden spike in NXDOMAIN responses from a single source IP is a strong indicator of active tunneling.
Adversary DNS servers may use complex CNAME chains to redirect traffic through multiple layers of resolution. Unusually deep or circular CNAME chains should be investigated as potential redirection attacks.
DNS server acquisition is one component of the broader Acquire Infrastructure (T1583) tactic. Understanding the full infrastructure acquisition lifecycle, from domains and hosting to DNS servers and email accounts, provides defenders with a comprehensive view of how adversaries build operational capabilities.
Key Takeaways:
✅ DNS is trusted by default, Every organization must assume DNS-based C2 is a possibility and implement monitoring accordingly.
✅ Conditional responses are the silent killer, Adversary DNS servers can appear completely normal while selectively serving malware commands.
✅ Passive DNS is your friend, Historical DNS records help identify adversary infrastructure before it's used against your organization.
✅ Tunneling detection requires specialized tools, Standard firewalls cannot detect DNS tunneling. Deploy dedicated DNS security platforms with entropy analysis and anomaly detection.
Every contribution moves us closer to our goal: making world-class cybersecurity education accessible to ALL.
Choose the amount of donation by yourself.