DNS (53)

  • DNS Record: Description
  • A: Returns an IPv4 address for the requested domain.
  • AAAA: Returns an IPv6 address for the requested domain.
  • MX: Returns the mail servers responsible for the domain.
  • NS: Returns the domain's DNS servers (nameservers).
  • TXT: Stores miscellaneous information, such as Google Search Console validations or SSL certificates. It also contains SPF and DMARC records to validate and protect email against spam.
  • CNAME: Acts as an alias for another domain name. For example, if you want www.hackthebox.eu to point to the same IP as hackthebox.eu, you would create an A record for hackthebox.eu and a CNAME for www.hackthebox.eu.
  • PTR: Performs reverse lookups, converting IP addresses into domain names.
  • SOA: Provides information about the DNS zone and the administrative contact.
Basic dig query
terminal
dig any victim.com @<DNS_IP>
Query to retrieve MX records
terminal
dig mx victim.com @<DNS_IP>

What Is a Zone Transfer?

If the server is misconfigured, we can retrieve all records by performing a zone transfer to our server.
terminal
dig axfr victim.com @<DNS_IP>

Refused Responses

In some cases, ANY queries or queries for other records may be refused, which is indicated in the response.
bash
; <<>> DiG 9.20.2 <<>> any internal.inlanefreight.htb @10.129.147.247;; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 6734
The status is REFUSED.

DNS Fuzzing

terminal
dnsenum --dnsserver <ip> --enum -p 0 -s 0 -o subdominions.txt -f ~/wordlists/fierce-hostlist.txt <dominio>

Example

terminal
dig axfr inlanefreight.htb @10.129.147.247
terminal
inlanefreight.htb.	604800	IN	SOA	inlanefreight.htb. root.inlanefreight.htb. 2 604800 86400 2419200 604800inlanefreight.htb.	604800	IN	TXT	"MS=ms97310371"inlanefreight.htb.	604800	IN	NS	ns.inlanefreight.htb.app.inlanefreight.htb.	604800	IN	A	10.129.18.15dev.inlanefreight.htb.	604800	IN	A	10.12.0.1internal.inlanefreight.htb. 604800 IN	A	10.129.1.6mail1.inlanefreight.htb. 604800	IN	A	10.129.18.201ns.inlanefreight.htb.	604800	IN	A	127.0.0.1
We obtained the following internal subdomains and can now run dig against them, for example:
terminal
dig axfr internal.inlanefreight.htb @10.129.147.247
terminal
internal.inlanefreight.htb. 604800 IN	SOA	inlanefreight.htb. root.inlanefreight.htb. 2 604800 86400 2419200 604800internal.inlanefreight.htb. 604800 IN	NS	ns.inlanefreight.htb.dc1.internal.inlanefreight.htb.	604800	IN A	10.129.34.16dc2.internal.inlanefreight.htb.	604800	IN A	10.129.34.11mail1.internal.inlanefreight.htb. 604800	IN A	10.129.18.200vpn.internal.inlanefreight.htb.	604800	IN A	10.129.1.6ws1.internal.inlanefreight.htb.	604800	IN A	10.129.1.34ws2.internal.inlanefreight.htb.	604800	IN A	10.129.1.35wsus.internal.inlanefreight.htb. 604800	IN A	10.129.18.2