DNS spoof/poison
Domain Name System (DNS) spoofing involves sending fake and malicious DNS query to a target machine, causing its DNS cache to be poisoned.
This attack exploits the fact that DNS is not encrypted by default, which makes it vulnerable to sniffing and modifications.
On a local network, DNS spoofing can be used as an additional vector of attack after the initial man-in-the-middle position have been established. A particular use case of DNS spoofing would be to further escalate the attack, for example to allow resolution of domain/host names that are previously non-existent - but still seemingly legitimate.
This could be done for subdomains of trusted websites. For example, lets assume there's a website that a user visits often, and trusts: jarrett.gohxiangzheng.com. If a new subdomain: trustme.gohxiangzheng.com, with the same root domain name (gohxiangzheng.com) is encountered by the user, it is more likely to be trusted. The caveat is that the fake subdomain mentioned above does not need to actually exist, and this technique would work as long as the malicious DNS server has means of resolving it.
Suppose the user's local DNS cache has an existing record for jarrett.gohxiangzheng.com. However, it does not apply for the new fake subdomain, and the machine would still be required to perform a DNS lookup. If a MitM situation has been established by the attacker between the user and gateway, the DNS query would be sent to the malicious server instead, which would poison the user's cache with a fake entry pointing to the attacker controlled IP address.
In summary, a DNS spoofing/poisoning attack allows the following to happen:
DNS resolution of a previously non-existent, but seemingly legitimate host name
Bypass of the user's local DNS cache
dSniff's dnsspoof tool
Installation
Usage
Load a DNS hosts file with entries
Run a DNS server on a particular interface, with given hosts file content at path
Example: Run a DNS server on the interface eth0 to resolve queries for any subdomain of gohxiangzheng.com to the IP address 10.10.10.10 - hosts file name is hosts.spoof
NOTE: Ensure that port forwarding is disabled on the attacker machine (seems to be disabled by default on Kali)
This is to prevent the machine from forwarding the DNS query to the actual gateway, which might potentially cause a race condition, such that the victim receive the DNS reply from the actual gateway first, affecting the effectiveness of the attack
To verify if its enabled/disabled (returns 0 if disabled, else 1)
Alternative method
However, if IP forwarding is required on the attacker machine, a direct approach can be taken instead:
Drop all DNS queries (UDP port 53) destined for the actual gateway address
Or simply drop all DNS queries received, and prevent it from being forwarded
Demonstration
Assume the following parameters:
Victim machine
Windows
10.0.2.4
Attacker machine
Kali Linux
10.0.2.5
Actual gateway
10.0.2.1
Attacker machine: Run a malicious DNS server (assume a MitM position has been established)
Victim machine: Ping a subdomain of the target root domain (trustme.gohxiangzheng.com)
This would elicit a DNS lookup for the requested host name
Attacker machine: DNS query display
Following the ping request from the victim machine, the DNS query would be received by the attacker machine and the following would output from the dnsspoof command
A Wireshark window on the attacker machine, with the filter dns && ip.addr == 10.0.2.4 would display the DNS query from the victim machine
This causes the host name trustme.gohxiangzheng.com to be resolved to the IP address 10.0.2.5 - an actual DNS server would not resolve it, as it does not actually exists
Victim machine: Poisoning of the victim's local DNS cache
Consequently, the DNS cache would be poisoned with a false entry
View & flush DNS cache on Windows
To view the local DNS cache
To flush the local DNS cache
Prevention methods
1. Use secure DNS
Virtual Private Network (VPN) providers
Third-party security software
Browser built-in secure DNS
This can be achieved with DNSSEC, DNS over HTTPS (DoH), etc. This allows DNS traffic to be encrypted, which prevents sniffing and malicious modifications of data.
Last updated