DC Sync Attack: The Art of Impersonation
An in-depth technical guide to the DC Sync attack, explaining how attackers abuse Active Directory replication protocols to dump credentials without touching the disk.
Feb 15, 2026Windows
dig Command: Red & Blue Team PerspectivesThe dig (Domain Information Groper) command is one of the most powerful tools for interacting with the Domain Name System (DNS). It’s often used by system administrators, network engineers, penetration testers, and defenders to troubleshoot DNS issues, gather intelligence, or detect suspicious activities.
This article will walk you through dig fundamentals, provide code samples, explore red team vs. blue team use cases, and share pro tips for advanced usage.
dig?dig is a DNS lookup utility that queries DNS servers directly. Unlike simple commands like nslookup, dig provides detailed output about DNS responses, including query times, authoritative servers, and record types.
Typical syntax:
dig [@server] domain [type]@server → optional DNS server to querydomain → the target domain nametype → record type (A, AAAA, MX, TXT, NS, etc.)dig commanddig example.com AFind mail servers, lookup MX records
dig example.com MXCheck if all name servers are expected and correct. Get authoritative name servers
dig example.com NS Avoid depending solely on your default DNS resolver. For authoritative and unaltered results, query a domain's authoritative name servers directly. You can discover these servers with a standard dig lookup, then run dig @<ns-server> <domain> to query them specifically.
dig @8.8.8.8 example.comIf a firewall or proxy log flags a suspicious IP address, this command can resolve it to its corresponding hostname. This may uncover the domain linked to a potential command-and-control (C2) server.
dig -x 93.184.216.34dig +short example.comFor attackers and penetration testers, dig is a reconnaissance tool to map out DNS infrastructure.
If misconfigured, DNS servers may allow AXFR (zone transfer) queries:
dig @ns1.example.com example.com AXFRMany organizations disable this, but if it works, you gain the entire DNS zone file, exposing internal hosts and services.
By querying authoritative name servers or brute forcing:
for sub in www mail vpn dev; do
dig +short $sub.example.com
doneMail servers can reveal third-party services or attack vectors:
dig example.com MX +shortAttackers look for SPF/DKIM/DMARC or internal notes:
dig example.com TXTDefenders use dig for monitoring, validation, and incident response.
dig example.com @1.1.1.1
dig example.com @8.8.8.8If results differ, it may indicate DNS poisoning or manipulation.
Regularly test your own DNS servers:
dig @ns1.yourdomain.com yourdomain.com AXFRIf it responds, fix immediately by restricting transfers.
dig example.com TXTEnsure SPF, DKIM, and DMARC are properly set.
If an alert flags a suspicious domain:
dig bad-domain.xyz ANYHelps defenders see if attackers are using dynamic DNS or fast-flux.
digUse +trace to follow resolution from root servers:
dig example.com +traceUse +nocmd +noquestion +noauthority +noadditional +nostats for clean outputs:
dig example.com A +shortBatch query multiple records:
dig example.com A example.com MX example.com TXTCombine with grep/awk for automation:
dig example.com MX +short | awk '{print $2}'Because attackers often use them to exfiltrate data. DNS tunneling works by encoding data from an internal host into DNS queries and responses, which can bypass firewalls that are configured to allow DNS traffic. While A and MX records are also used, TXT records are particularly well-suited for tunneling because they can hold arbitrary string data up to 255 characters per string. This makes them an ideal container for small chunks of data. To check for unusual TXT records, you'll need to use dig with the TXT option.
dig suspicious.com TXTA normal response for a legitimate domain might contain things like SPF (Sender Policy Framework) or DKIM (DomainKeys Identified Mail) records, which are used to prevent email spoofing.
Normal TXT Record Example:
example.com. 86400 IN TXT "v=spf1 include:_spf.google.com ~all"This is a standard SPF record. It's concise and follows a predictable format.
Look for TXT records that contain unusually long or highly random-looking strings of characters. These often don't follow the structured format of legitimate records like SPF or DKIM.
Suspicious TXT Record Example:
example.com. 86400 IN TXT "t9G9s7kP2xL5hJ8rD4nB3qM1fC6aZ7eG5l8iK9oP2uY4tX3wV1z7t9rS6jK4fH8gD3oN1eQ2xL5cI8bU3vP1wS4fG7jK8hL2pB9nD4qC6aZ7eG5iL8kS9oP2uY4tX3wV1z7t9rS6jK4fH8gD3oN1eQ2xL5cI8bU3vP1wS4fG7jK8hL2pB9nD4qC6"This string of characters is far too long and random to be a normal DNS record. It is likely encoded data being exfiltrated from a compromised system.
Correlate with Other Indicators To confirm a DNS tunneling threat, you need to look for other indicators in your network traffic logs.
| Indicator | Description |
|---|---|
| High Volume of Queries | A single compromised host will likely generate a large number of DNS queries to the same domain over a short period. Look for an unusually high frequency of DNS requests from a specific internal IP address. |
| Sequential DNS Queries | The queries may follow a sequential pattern (e.g., part1.malicious.com, part2.malicious.com, etc.) as the data is broken down into smaller chunks. |
| Unusual Domain Names | The domain itself may be recently registered or have a low reputation score. Tools like VirusTotal can help with this. |
To streamline your investigation, you can script dig to automatically check for TXT records on a list of suspicious domains and then pipe the output to a tool that can analyze the strings for randomness or length.
The dig command is indispensable for both attackers and defenders.
By mastering dig, you not only gain visibility into DNS but also sharpen your skills in both offense and defense.
Love it? Share this article: