Cyber Pulse Academy

Latest News
T1583.002

DNS Server

Adversaries may set up their own DNS servers for C2 channels, credential capture, and adversary-in-the-middle attacks during targeting operations.

Resource Development, TA0042 Acquire Infrastructure

DNS Query/Response Flow & Tunneling

CSS-ONLY SIM
dns-tunnel-monitor, adversarial DNS server LIVE
💻
Victim Client
Malware sends encoded DNS queries to adversary-controlled server
⚠️
Adversary DNS
Custom authoritative server decodes queries, returns C2 via TXT records
📦
C2 Response
Malicious DNS responses contain encoded commands and instructions
🔒
Data Exfil
Stolen data encoded in subdomain labels sent as DNS queries
Query Log, Real-time DNS Tunnel Activity 8 entries
[14:23:05] QUERY c2hlbG ... xf1a.data.attacker.net → A
[14:23:06] RESP 104.21.x.x (malicious redirect)
[14:23:12] QUERY ZXhmaW ... bGF0.exfil.attacker.net → CNAME
[14:23:12] RESP collect.attacker.net (data exfil path)
[14:23:18] QUERY Y3JlZ ... mVudA.cred.attacker.net → TXT
[14:23:19] ⚠ ALERT Credential capture: user=admin, pass=b64...
DNS Tunneling TXT Record C2 Data Exfiltration Conditional Response Credential Capture

Why DNS Server Acquisition Matters

⚠️

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.

The Invisible C2 Channel

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.

82%
Of malware uses DNS for C2 communications
91%
Of organizations lack DNS traffic monitoring
3.5M+
DNS tunneling queries detected daily globally
53%
Of data exfiltration incidents use DNS channels
Core Threat

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.

Key Terms & Concepts

Definition

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.

Everyday Analogy

📞 “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.

🔌 DNS Tunneling

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.

📄 TXT Record C2

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.

🔒 DNS Hijacking

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.

⚡ Conditional Responses

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.

🔐 DNS over HTTPS (DoH)

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.

Term Port/Protocol Role in Attack Detection Difficulty DNS Tunneling 53/UDP, 53/TCP C2 channel & data exfiltration High TXT Record C2 53/UDP Command delivery Medium DNS Hijacking 53/UDP Traffic redirection Medium Conditional Response 53/UDP Targeted payload delivery High DoH Tunneling 443/TCP Encrypted C2 evasion Very High

Real-World Scenario: Alexei Morozov

🏠 The Operator: Alexei Morozov, Infrastructure Architect

“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.

🚀 Phase 1: Infrastructure Setup

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.

⚡ Phase 2: Conditional DNS Configuration

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.

🔒 Phase 3: Credential Capture via DNS Redirection

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.

📦 Phase 4: Data Exfiltration via DNS Tunneling

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.

📈 Phase 5: Operational Impact

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.

🛡️ Detection: Passive DNS Tracking Reveals the Pattern

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.

Step-by-Step Operational Guide

🛡️

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.

01

Deploy DNS Server Infrastructure

Acquire and provision VPS or dedicated servers in multiple jurisdictions to create a resilient DNS infrastructure.

  • Lease servers from providers that accept cryptocurrency and require minimal identity verification
  • Install DNS server software (BIND9, Unbound, PowerDNS, or CoreDNS) and configure as authoritative nameserver
  • Establish redundant servers across multiple geographic regions to ensure availability and resist takedown
VET PROVIDERS PASSIVE DNS
02

Configure DNS Software

Set up the DNS server with custom zone files, response policies, and logging infrastructure.

  • Configure zone files for registered domains (T1583.001) with appropriate NS, A, TXT, and CNAME records
  • Implement Response Policy Zones (RPZ) for conditional response logic based on query patterns
  • Set up comprehensive query logging to capture all incoming DNS requests for intelligence gathering
RPZ MONITORING ZONE AUDIT
03

Set Up Conditional Responses

Configure the DNS server to serve different responses based on query characteristics and source identification.

  • Create response rules that identify malware by encoded subdomain prefixes or specific query patterns
  • Configure normal resolution for all non-malicious queries to avoid generating suspicious traffic patterns
  • Implement geolocation-based responses to target specific regions while maintaining cover in others
ANOMALY DETECTION DNS ANALYTICS
04

Implement C2 Channel via DNS Records

Build the command-and-control communication channel using DNS record types as the transport mechanism.

  • Configure TXT record responses to deliver base64-encoded commands to malware implants on victim networks
  • Set up CNAME record chains to redirect specific internal hostname lookups to attacker-controlled impersonation servers
  • Implement data exfiltration by logging encoded subdomain queries and reassembling extracted data chunks server-side
TXT MONITORING EGRESS FILTERING
05

Test and Validate DNS Tunneling

Conduct thorough testing of the DNS tunneling channel to ensure reliability, performance, and stealth.

  • Test bandwidth throughput of the DNS tunnel using standard tools and optimize encoding schemes for efficiency
  • Validate that the tunnel operates reliably through various DNS resolvers, corporate proxies, and firewall configurations
  • Verify that conditional responses correctly distinguish between legitimate and malware-sourced queries
ENTROPY ANALYSIS VOLUME ALERTS
06

Maintain Operational Security

Implement OPSEC measures to prevent detection and ensure long-term sustainability of the DNS infrastructure.

  • Rotate domains, nameserver IPs, and encoding keys on a regular schedule to avoid pattern detection (T1583.003)
  • Mimic legitimate DNS traffic patterns including appropriate query volumes, timing distributions, and failure rates
  • Implement Domain Generation Algorithms (DGA) or fast-flux techniques to make infrastructure tracking more difficult
DGA DETECTION FAST-FLUX ALERTS

Common Mistakes & Best Practices

❌ Common Mistakes (Attacker)

  • Using obviously suspicious domain names, Registering domains like “c2-evil-tunnel.ru” that immediately trigger threat intelligence feeds and automated blocking systems
  • Ignoring DNS query volume anomalies, Generating unusually high volumes of DNS queries from a single source IP that stands out against baseline network traffic patterns
  • Failing to mimic legitimate DNS patterns, Sending queries at perfectly regular intervals or generating subdomains with uniformly high entropy that lacks the variation of legitimate traffic
  • Reusing infrastructure across campaigns, Using the same nameserver IPs and domains for multiple operations, allowing researchers to correlate disparate attacks
  • Neglecting DNSSEC validation, Deploying DNS servers without proper DNSSEC configuration, allowing resolvers to detect tampered or unsigned responses

✅ Best Practices (Defender)

  • Deploy DNS monitoring and logging, Implement comprehensive DNS query logging at the resolver level to establish baselines and detect anomalous patterns including unusual query volumes and long subdomains
  • Use passive DNS replication, Subscribe to passive DNS databases that track historical DNS record changes, enabling detection of new infrastructure and domain registration patterns
  • Implement DNS filtering at the resolver, Deploy DNS-based threat intelligence feeds that block known malicious domains and detect newly registered domains matching campaign patterns
  • Monitor for DNS tunneling indicators, Alert on excessive TXT record queries, high-entropy subdomain labels, unusually long DNS queries exceeding 53 characters, and NXDOMAIN spike patterns
  • Enforce DNS-over-HTTPS policies, Control which DoH resolvers are permitted on the network, preventing malware from bypassing corporate DNS monitoring by using external encrypted resolvers

Red Team vs Blue Team View

RED TEAM

👁 Offensive Perspective

  • Stealthy C2 Channel: DNS is universally permitted through firewalls, making it the ideal covert channel that requires zero additional firewall rules to establish. The protocol's simplicity and ubiquity are the adversary's greatest advantage.
  • Credential Capture via Redirection: By resolving internal service names to attacker-controlled IPs, the adversary can impersonate email portals, VPN gateways, and internal tools to harvest enterprise credentials at scale.
  • Flexible Tunnel Architecture: Custom DNS servers support multiple encoding schemes, conditional responses, and dynamic reconfiguration. The entire C2 channel can be modified server-side without touching the malware implant.
  • Data Exfiltration at Scale: DNS tunneling supports bidirectional data transfer. Encoded subdomain labels carry stolen data out, while TXT record responses carry commands in. Both directions appear as normal DNS traffic to untrained observers.
  • Resilience Through Distribution: Multiple authoritative nameservers across diverse hosting providers create a fault-tolerant infrastructure that resists takedown. Domain rotation adds another layer of persistence.
BLUE TEAM

🛡️ Defensive Perspective

  • DNS Monitoring and Baselining: Deploy DNS query logging at the organizational resolver to establish baseline patterns. Anomalies like unusual query volumes, long subdomains, and frequent TXT lookups warrant investigation.
  • Anomaly Detection Algorithms: Implement machine learning models that detect DNS tunneling by analyzing subdomain entropy, query length distributions, query frequency patterns, and NXDOMAIN response rates.
  • Passive DNS Tracking: Maintain historical DNS records to track adversary infrastructure. Correlate newly observed domains, nameserver IP clusters, and record changes across multiple data sources to identify campaign infrastructure.
  • DNS Filtering and Threat Intel: Integrate DNS resolver with threat intelligence feeds that block known malicious domains in real-time. Implement RPZ (Response Policy Zone) to override malicious resolutions before they reach the client.
  • Egress Filtering and Protocol Enforcement: Restrict which external DNS resolvers clients can use. Block or redirect DoH traffic to approved resolvers. Monitor for direct DNS queries to non-corporate resolvers that bypass monitoring.

Related techniques for comprehensive infrastructure analysis:

Threat Hunter’s Eye

🔎 Hunting Hypotheses for Adversary DNS Servers

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.

Hypothesis 1: Unusual DNS Query Patterns

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.

index=dns sourcetype=dns length(query)>53 | stats count by query | where count < 5 | sort -count

Hypothesis 2: Excessive TXT Record Queries

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.

index=dns record_type=TXT | stats count dc(src_ip) as unique_sources by domain | where count > 100 | sort -count

Hypothesis 3: DNS Tunneling Detection via Entropy

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.

index=dns | eval subdomain=mvindex(split(query,"."),0) | eval entropy=entropy(subdomain) | where entropy > 3.8 | table _time src_ip query subdomain entropy

Hypothesis 4: Long Domain Queries (Spike Pattern)

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.

index=dns | eval q_len=len(query) | stats avg(q_len) as avg_len max(q_len) as max_len count by src_ip,hour | where max_len > 60 | sort -max_len

Hypothesis 5: NXDOMAIN Spike from Single Source

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.

index=dns response_code=NXDOMAIN | stats count by src_ip | where count > 50 | sort -count

Hypothesis 6: Unusual CNAME Chain Patterns

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.

index=dns record_type=CNAME | transaction query startswith="CN" | where eventcount > 4 | table _time query rdata
>53
Character threshold for suspicious DNS queries
3.8+
Shannon entropy threshold for encoded subdomains
50+
NXDOMAIN/min threshold per source IP for alerts
100+
TXT queries/day to same domain triggers investigation

Continue Your Investigation

Explore Related MITRE ATT&CK Techniques

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.

External References

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.

DNS Server


DONATE · SUPPORT

We keep threat intelligence free. No paywalls, no ads. Your donation directly funds server infrastructure, research, and tools. Every contribution - no matter the size - makes this platform sustainable.
100% of your support goes to the platform. No corporate sponsors, just the community.
ROOT::DONATE

Leave a Comment

Your email address will not be published. Required fields are marked *



Ask ChatGPT
Set ChatGPT API key
Find your Secret API key in your ChatGPT User settings and paste it here to connect ChatGPT with your Courses LMS website.
Certification Courses
Hands-On Labs
Threat Intelligence
Latest Cyber News
MITRE ATT&CK Breakdown
All Cyber Keywords

Every contribution moves us closer to our goal: making world-class cybersecurity education accessible to ALL.

Choose the amount of donation by yourself.