
Imagine you want to visit a website like www.example.com. You type this friendly domain name into your browser, but your computer doesn't understand words – it speaks the language of numbers, specifically IP addresses. So, how does your computer find the website's IP address? Enter DNS, the internet's trusty translator.
Hosts file
Maps hostnames to ip addresses, manual method of domain name resolution that bypasses DNS process. DNS automates translation of domain names to IPs, hosts file allows for direct local overrides. Useful for dev/troubleshoot/blocking of websites.
Key concepts
IN DNS, zone is a distinct part of domain namespace that specific entity/admin manages. Think of it like a virtual container for a set of domain names.
i.e. example.com and all subdomains mail.example.com , blog.example.com - typically belong to same dns zone.
Zone file - text file residing on dns server - defines records within this zone, providing crucial information for translating domain names into IP addresses. Example zone file:
Code: zone
dns-zone
$TTL 3600 ; Default Time-To-Live (1 hour)
@ IN SOA ns1.example.com. admin.example.com. (
2024060401 ; Serial number (YYYYMMDDNN)
3600 ; Refresh interval
900 ; Retry interval
604800 ; Expire time
86400 ) ; Minimum TTL
@ IN NS ns1.example.com.
@ IN NS ns2.example.com.
@ IN MX 10 mail.example.com.
www IN A 192.0.2.1
mail IN A 198.51.100.1
ftp IN CNAME www.example.com.
This file defines the authoritative name servers (`NS` records), mail server (`MX` record), and IP addresses (`A` records) for various hosts within the `example.com` domain.

IN stands for Internet. Other class values exist (e.g., CH for Chaosnet, HS for Hesiod) but are rarely used in modern DNS configurations.

DNS tooling
DIG:
| Command | Description |
|---|---|
dig domain.com |
Performs a default A record lookup for the domain. |
dig domain.com A |
Retrieves the IPv4 address (A record) associated with the domain. |
dig domain.com AAAA |
Retrieves the IPv6 address (AAAA record) associated with the domain. |
dig domain.com MX |
Finds the mail servers (MX records) responsible for the domain. |
dig domain.com NS |
Identifies the authoritative name servers for the domain. |
dig domain.com TXT |
Retrieves any TXT records associated with the domain. |
dig domain.com CNAME |
Retrieves the canonical name (CNAME) record for the domain. |
dig domain.com SOA |
Retrieves the start of authority (SOA) record for the domain. |
dig @1.1.1.1 domain.com |
Specifies a specific name server to query; in this case 1.1.1.1 |
dig +trace domain.com |
Shows the full path of DNS resolution. |
dig -x 192.168.1.1 |
Performs a reverse lookup on the IP address 192.168.1.1 to find the associated host name. You may need to specify a name server. |
dig +short domain.com |
Provides a short, concise answer to the query. |
dig +noall +answer domain.com |
Displays only the answer section of the query output. |
dig domain.com ANY |
Retrieves all available DNS records for the domain (Note: Many DNS servers ignore ANY queries to reduce load and prevent abuse, as per RFC 8482). |
Tools for subdomain bruteforcing / enumeration
| Tool | Description |
|---|---|
| dnsenum | Comprehensive DNS enumeration tool that supports dictionary and brute-force attacks for discovering subdomains. |
| fierce | User-friendly tool for recursive subdomain discovery, featuring wildcard detection and an easy-to-use interface. |
| dnsrecon | Versatile tool that combines multiple DNS reconnaissance techniques and offers customisable output formats. |
| amass | Actively maintained tool focused on subdomain discovery, known for its integration with other tools and extensive data sources. |
| assetfinder | Simple yet effective tool for finding subdomains using various techniques, ideal for quick and lightweight scans. |
| puredns | Powerful and flexible DNS brute-forcing tool, capable of resolving and filtering results effectively. |
dnsenum --enum inlanefreight.com -f /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt -r
-r: This option enables recursive subdomain brute-forcing
ZONE TRANSFERS
A DNS zone transfer is essentially a wholesale copy of all DNS records within a zone (a domain and its subdomains) from one name server to another. This process is essential for maintaining consistency and redundancy across DNS servers. However, if not adequately secured, unauthorised parties can download the entire zone file, revealing a complete list of subdomains, their associated IP addresses, and other sensitive DNS data.
ex:
┌──(root㉿kali)-[~/cpts/module-enum/hard]
└─# dig axfr @10.129.119.236 inlanefreight.htb
; <<>> DiG 9.19.25-185-g392e7199df2-1-Debian <<>> axfr @10.129.119.236 inlanefreight.htb
; (1 server found)
;; global options: +cmd
inlanefreight.htb. 604800 IN SOA inlanefreight.htb. root.inlanefreight.htb. 2 604800 86400 2419200 604800
inlanefreight.htb. 604800 IN NS ns.inlanefreight.htb.
admin.inlanefreight.htb. 604800 IN A 10.10.34.2
ftp.admin.inlanefreight.htb. 604800 IN A 10.10.34.2
careers.inlanefreight.htb. 604800 IN A 10.10.34.50
dc1.inlanefreight.htb. 604800 IN A 10.10.34.16
dc2.inlanefreight.htb. 604800 IN A 10.10.34.11
internal.inlanefreight.htb. 604800 IN A 127.0.0.1
admin.internal.inlanefreight.htb. 604800 IN A 10.10.1.11
wsus.internal.inlanefreight.htb. 604800 IN A 10.10.1.240
ir.inlanefreight.htb. 604800 IN A 10.10.45.5
dev.ir.inlanefreight.htb. 604800 IN A 10.10.45.6
ns.inlanefreight.htb. 604800 IN A 127.0.0.1
resources.inlanefreight.htb. 604800 IN A 10.10.34.100
securemessaging.inlanefreight.htb. 604800 IN A 10.10.34.52
test1.inlanefreight.htb. 604800 IN A 10.10.34.101
us.inlanefreight.htb. 604800 IN A 10.10.200.5
cluster14.us.inlanefreight.htb. 604800 IN A 10.10.200.14
messagecenter.us.inlanefreight.htb. 604800 IN A 10.10.200.10
ww02.inlanefreight.htb. 604800 IN A 10.10.34.112
www1.inlanefreight.htb. 604800 IN A 10.10.34.111
inlanefreight.htb. 604800 IN SOA inlanefreight.htb. root.inlanefreight.htb. 2 604800 86400 2419200 604800
;; Query time: 44 msec
;; SERVER: 10.129.119.236#53(10.129.119.236) (TCP)
;; WHEN: Wed Jul 17 19:33:45 EDT 2024
;; XFR size: 22 records (messages 1, bytes 594)
Virtual Hosts
At the core of virtual hosting is the ability of web servers to distinguish between multiple websites or applications sharing the same IP address. This is achieved by leveraging the HTTP Host header, a piece of information included in every HTTP request sent by a web browser.
The key difference between VHosts and subdomains is their relationship to the Domain Name System (DNS) and the web server's configuration.
Subdomains: These are extensions of a main domain name (e.g.,blog.example.comis a subdomain ofexample.com).Subdomainstypically have their ownDNS records, pointing to either the same IP address as the main domain or a different one. They can be used to organise different sections or services of a website.Virtual Hosts(VHosts): Virtual hosts are configurations within a web server that allow multiple websites or applications to be hosted on a single server. They can be associated with top-level domains (e.g.,example.com) or subdomains (e.g.,dev.example.com). Each virtual host can have its own separate configuration, enabling precise control over how requests are handled.
If a virtual host does not have a DNS record, you can still access it by modifying the hosts file on your local machine. The hosts file allows you to map a domain name to an IP address manually, bypassing DNS resolution.


3 primary types of vhosting:
- Name-based vhost
- Relies solely on http host header. Most common and flexible. Cost effective, easy. Requires web server to support name-based vhost ; have limitations
- IP-Based vhost
- Assigns unique ip addr to each website hosted on server. Server determines which site to server based on ip addr to which req was sent. Doesnt rely on host header - used with any protocol - offers better isolation btwn sites. Multiple ip addrs = more expensive, less scalable
- Port-based vhost
- Diff websites associated with diff ports on the same ip addr. One website accessible p80, another on p8080. Port-based vhost used when ip addr are limited but not as common/friendly as name-based vhost and might require users to specify port in the url.
Discovery tools:
gobuster feroxbuster ffuf
gobuster vhost -u http://inlanefreight.htb:81 -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt --append-domain
***IMPORTANT NOTE ABOUT VHOSTS - Make sure that you put in your /etc/hosts file an entry for the domain and specify (domain):(port) in gobuster like above. Do not try to get vhosts with a direct IP, it just won't work and you will be mad https://academy.hackthebox.com/module/144/section/1257