The Domain Name Systems \(DNS\) is the phonebook of the Internet. Humans access information online through domain names, like nytimes.com or espn.com. Web browsers interact through Internet Protocol \(IP\) addresses. DN S translates domain names to [IP addresses](https://www.cloudflare.com/learning/dns/glossary/what-is-my-ip-address/) so browsers can load Internet resources.
From [here](https://www.cloudflare.com/learning/dns/what-is-dns/).
**Default port:** 53
```text
PORT STATE SERVICE REASON
53/tcp open domain Microsoft DNS 6.1.7601 (1DB15D39) (Windows Server 2008 R2 SP1)
5353/udp open zeroconf udp-response
53/udp open domain Microsoft DNS 6.1.7601 (1DB15D39) (Windows Server 2008 R2 SP1)
```
## Enumeration
### **Banner Grabbing**
DNS does not have a "banner" to grab. The closest equivalent is a magic query for `version.bind. CHAOS TXT` which will work on most BIND nameservers.
You can perform this query using `dig`:
```bash
dig version.bind CHAOS TXT @DNS
```
If that does not work you can use fingerprinting techniques to determine the remote server's version -- the [`fpdns`](https://github.com/kirei/fpdns) tool is one option for that, but there are others.
You can grab the banner also with a **nmap** script:
```text
--script dns-nsid
```
### **Zone Transfer**
```bash
dig axfr @<DNS_IP>#Try zone transfer without domain
dig axfr @<DNS_IP><DOMAIN>#Try zone transfer guessing the domain
fierce --domain <DOMAIN> --dns-servers <DNS_IP>#Will try toperform a zone transfer against every authoritative name server and if this doesn'twork, will launch a dictionary attack
If you are able to find subdomains resolving to internal IP-addresses, you should try to perform a reverse dns BF to the NSs of the domain asking for that IP range.
Another tool to do so: [https://github.com/amine7536/reverse-scan](https://github.com/amine7536/reverse-scan)
You can query reverse IP ranges to [https://bgp.he.net/net/205.166.76.0/24\#\_dns](https://bgp.he.net/net/205.166.76.0/24#_dns) \(this tool is also helpful with BGP\).
Brute force using "AAAA" requests to gather IPv6 of the subdomains.
```bash
dnsdict6 -s -t <domain>
```
Bruteforce reverse DNS in using IPv6 addresses
```bash
dnsrevenum6 pri.authdns.ripe.net 2001:67c:2e8::/48 #Will use the dns pri.authdns.ripe.net
```
### DNS Recursion DDoS
If **DNS recursion is enabled**, an attacker could **spoof** the **origin** on the UDP packet in order to make the **DNS send the response to the victim server**. An attacker could abuse **ANY** or **DNSSEC** record types as they use to have the bigger responses.
The way to **check** if a DNS supports **recursion** is to query a domain name and **check** if the **flag "ra"** \(_recursion available_\) is in the response:
```bash
dig google.com A @<IP>
```
**Non available**:
![](../.gitbook/assets/image%20%28155%29.png)
**Available**:
![](../.gitbook/assets/image%20%28139%29.png)
### Mail to nonexistent account
From book: Network Security Assessment \(3rd edition\)
Simply sending an email message to a nonexistent address at a target domain often reveals useful internal network information through a _nondelivery notification_ \(NDN\).
```text
Generating server: noa.nintendo.com
blah@nintendo.com
#550 5.1.1 RESOLVER.ADR.RecipNotFound; not found ##
Original message headers:
Received: from ONERDEDGE02.one.nintendo.com (10.13.20.35) by
onerdexch08.one.nintendo.com (10.13.30.39) with Microsoft SMTP Server (TLS)
id 14.3.174.1; Sat, 26 Apr 2014 16:52:22 -0700
Received: from barracuda.noa.nintendo.com (205.166.76.35) by
ONERDEDGE02.one.nintendo.com (10.13.20.35) with Microsoft SMTP Server (TLS)