Domain 2Web App AttacksCORE

DNS and Web Request Resolution

DNS resolution mechanics, record types, exploitation techniques including subdomain takeover and zone transfers, essential for web application reconnaissance.

Domain: Domain 2: Web Application Penetration Testing•Updated: 2026-09-01
#dns#resolution#subdomain-takeover#reconnaissance#oscp

DNS and Web Request Resolution

Overview

DNS (Domain Name System) translates human-readable domain names into IP addresses. For OSCP, DNS is critical for reconnaissance — discovering subdomains, internal hostnames, and infrastructure details that expand your attack surface. DNS misconfigurations can lead to subdomain takeovers, information disclosure, and even direct access to internal services.

DNS Resolution Flow

How a Web Request Resolves

Step 1: Browser Cache
  └─ Check if domain is cached locally

Step 2: OS DNS Cache
  └─ Check /etc/hosts (Linux) or C:\Windows\System32\drivers\etc\hosts (Windows)

Step 3: Recursive DNS Resolver
  └─ Query ISP's DNS server or public DNS (8.8.8.8, 1.1.1.1)

Step 4: Root DNS Server
  └─ ".com" TLD server reference

Step 5: TLD DNS Server
  └─ Authoritative nameserver for example.com

Step 6: Authoritative DNS Server
  └─ Returns A record: 93.184.216.34

Step 7: Response Caching
  └─ Resolver caches result (TTL-based)

Step 8: TCP Connection
  └─ Browser connects to 93.184.216.34:80/443

DNS Record Types

Record Type Purpose Example OSCP Relevance
A IPv4 address 93.184.216.34 Primary target discovery
AAAA IPv6 address 2606:2800:220:1:248:1893:25c8:1946 IPv6 attack surface
CNAME Alias/redirect www -> example.com Subdomain takeover
MX Mail server mail.example.com Email infrastructure mapping
TXT Text records SPF, DKIM, verification SPF/DKIM analysis
NS Name servers ns1.example.com DNS hijacking, zone transfer
SOA Start of Authority Zone admin info Administrative details
SRV Service location _sip._tcp.example.com Service discovery
PTR Reverse DNS 34.216.184.93.in-addr.arpa Reverse lookup spoofing
CAA Certificate Authority issue "letsencrypt.org" Certificate analysis

DNS Attack Vectors

1. DNS Zone Transfer (AXFR)

Concept: Request a complete copy of a DNS zone from a nameserver.

Why it matters: Zone transfers reveal ALL subdomains, internal hostnames, and infrastructure details.

# Attempt zone transfer
dig AXFR target.com @ns1.target.com

# Using nslookup
nslookup -type=AXFR target.com ns1.target.com

# Using host
host -t AXFR target.com ns1.target.com

Successful zone transfer output:

; <<>> DiG 9.16.1 <<>> AXFR target.com @ns1.target.com
;; ANSWER SECTION:
target.com.            3600   IN   SOA   ns1.target.com. admin.target.com. 2024010101 3600 900 604800 86400
target.com.            3600   IN   NS    ns1.target.com.
target.com.            3600   IN   NS    ns2.target.com.
target.com.            3600   IN   A     93.184.216.34
www.target.com.        3600   IN   A     93.184.216.34
mail.target.com.       3600   IN   A     93.184.216.35
dev.target.com.        3600   IN   A     10.0.1.50
staging.target.com.    3600   IN   A     10.0.1.51
internal.target.com.   3600   IN   A     192.168.1.100

OSCP Tip: Internal IPs in zone transfers are gold — they reveal the target’s internal network topology.

2. Subdomain Enumeration

Concept: Discover subdomains to expand the attack surface.

Why it matters: Subdomains may host development environments, admin panels, APIs, or legacy applications with weaker security.

# Using subfinder
subfinder -d target.com

# Using amass
amass enum -passive -d target.com

# Using gobuster DNS mode
gobuster dns -d target.com -w /usr/share/wordlists/seclists/Discovery/DNS/subdomains-top1million-5000.txt

# Using ffuf
ffuf -u http://FUZZ.target.com -w subdomains.txt -mc 200,301,302

# Using sublist3r
sublist3r -d target.com

Common subdomain patterns:

www, mail, ftp, dev, staging, test, admin, api, app, portal
vpn, intranet, internal, git, jenkins, jira, confluence
phpmyadmin, pma, db, database, redis, mongo
blog, shop, store, cdn, static, assets

3. Subdomain Takeover

Concept: Claim an abandoned subdomain whose DNS record points to a service that no longer exists.

Why it matters: You can host malicious content on a subdomain of the target’s domain, enabling phishing, XSS, or credential theft.

How it works:

  1. A subdomain app.target.com has a CNAME record pointing to herokuapp.com.
  2. The company cancels their Heroku account.
  3. The CNAME still exists but points to nothing.
  4. You create a Heroku app with the same name → you now control app.target.com.

Detection:

# Check if subdomain resolves but returns error
curl -I http://app.target.com
# Returns: 404, 502, or "No website configured"

# Using subdomain takeover tools
git clone https://github.com/EdOverflow/can-i-take-over-xyz
python3 citox.py -u http://app.target.com

Common services vulnerable to takeover:

  • GitHub Pages (username.github.io)
  • Heroku (*.herokuapp.com)
  • AWS S3 (*.s3.amazonaws.com)
  • Azure Blob Storage (*.blob.core.windows.net)
  • Google Cloud Storage (storage.googleapis.com)
  • Shopify (*.myshopify.com)
  • Fastly (*.fastly.net)

4. DNS Spoofing / Cache Poisoning

Concept: Inject false DNS records into a resolver’s cache.

Why it matters: Redirect victims to attacker-controlled servers.

OSCP Relevance: Limited in exam environments, but understanding DNS security is important.

# Check DNSSEC status
dig DNSSEC target.com

# Check for DNSSEC records
dig DNSKEY target.com

5. DNS Rebinding

Concept: Use DNS to redirect a request from an external IP to an internal IP.

Why it matters: Bypass Same-Origin Policy to access internal services.

How it works:

  1. First request resolves to external IP (passes SOP check).
  2. DNS record changes to internal IP (127.0.0.1 or 192.168.x.x).
  3. Second request goes to internal service, still passing SOP.

DNS Tools and Commands

dig (Domain Information Groper)

# Basic A record query
dig target.com A

# Query specific nameserver
dig target.com A @8.8.8.8

# Query MX records
dig target.com MX

# Query TXT records
dig target.com TXT

# Query all records
dig target.com ANY

# Reverse DNS lookup
dig -x 93.184.216.34

# Zone transfer attempt
dig AXFR target.com @ns1.target.com

# Short output
dig +short target.com

nslookup

# Basic lookup
nslookup target.com

# Query specific server
nslookup target.com 8.8.8.8

# Query specific record type
nslookup -type=MX target.com

# Zone transfer
nslookup -type=AXFR target.com ns1.target.com

host

# Basic lookup
host target.com

# Reverse lookup
host 93.184.216.34

# Zone transfer
host -t AXFR target.com ns1.target.com

# Query specific record
host -t TXT target.com

Certificate Transparency Logs

# Search crt.sh for subdomains
# Visit: https://crt.sh/?q=%25.target.com

# Using crt.sh API
curl -s "https://crt.sh/?q=%25.target.com&output=json" | jq -r '.[].name_value' | sort -u

Practical Lab Exercises

Exercise 1: DNS Reconnaissance

Objective: Map the target’s DNS infrastructure.

# Step 1: Basic DNS queries
dig target.com ANY
dig target.com MX
dig target.com TXT

# Step 2: Zone transfer attempt
dig AXFR target.com @ns1.target.com

# Step 3: Subdomain enumeration
subfinder -d target.com -o subdomains.txt

# Step 4: Check certificate transparency
curl -s "https://crt.sh/?q=%25.target.com&output=json" | jq -r '.[].name_value' | sort -u

# Step 5: Resolve all subdomains
cat subdomains.txt | while read sub; do
  ip=$(dig +short "$sub.target.com")
  echo "$sub.target.com -> $ip"
done

Exercise 2: Subdomain Takeover Detection

Objective: Find and exploit a subdomain takeover vulnerability.

# Step 1: Enumerate subdomains
subfinder -d target.com | while read sub; do
  # Step 2: Check if subdomain resolves
  ip=$(dig +short "$sub.target.com")
  if [ -n "$ip" ]; then
    # Step 3: Check HTTP response
    status=$(curl -s -o /dev/null -w "%{http_code}" "http://$sub.target.com" --max-time 5)
    echo "$sub.target.com -> $ip -> HTTP $status"
  fi
done

# Step 4: Identify takeover candidates
# Look for: 404, 502, "No website configured", "Domain not found"
# Cross-reference with can-i-take-over-xyz database

Defensive Strategies

  1. Restrict Zone Transfers: Allow AXFR only from authorized secondary nameservers.
  2. Use DNSSEC: Sign DNS records to prevent cache poisoning.
  3. Monitor Subdomains: Regularly audit DNS records for dangling CNAMEs.
  4. Remove Unused Records: Clean up DNS records for decommissioned services.
  5. Use DNS Monitoring: Alert on unusual DNS query patterns.
  6. Implement DNS Filtering: Block known malicious domains.

Key Takeaways for OSCP

  1. DNS enumeration is your first step. Subdomains expand your attack surface significantly.

  2. Zone transfers are low-hanging fruit. Always try dig AXFR — misconfigured nameservers still exist.

  3. Subdomain takeover is exam-relevant. Abandoned subdomains can give you access to the target’s domain.

  4. Certificate transparency logs are free intel. crt.sh reveals subdomains that may not be actively enumerated.

  5. Internal IPs in DNS records are critical. They reveal the target’s internal network structure.

Exam Tips

  • Run subfinder and amass early in your assessment.
  • Always try zone transfers — they take seconds and can reveal everything.
  • Check crt.sh for historical subdomains.
  • When you find a subdomain, check it for the same vulnerabilities as the main domain.
  • Development and staging subdomains often have weaker security.