DNS Spoofing with Ettercap (For Ethical Penetration Testing Only)
DNS spoofing is an attack where a hacker tricks a target into visiting a fake website by responding with a forged DNS response. This can be used to redirect users to phishing sites or fake login pages. Use this only on networks you own or have explicit permission to test, as unauthorized use is illegal.
1. Setting Up Ettercap for DNS Spoofing
Step 1: Install Ettercap (If Not Installed)
On Kali Linux or Termux (with a Kali container), you can install Ettercap with:
or
Step 2: Enable IP Forwarding
Before running Ettercap, enable packet forwarding:
This allows packets to be forwarded between victims and the router.
Step 3: Configure DNS Spoofing
Edit the Ettercap DNS Spoofing File
Open theetter.dns
file:Add an entry for the domain you want to spoof. For example, to redirect
www.facebook.com
to a fake local web server (e.g.,192.168.1.100
):Save and exit (
CTRL+X
, thenY
, thenENTER
).Enable DNS Spoofing in Ettercap Open the Ettercap configuration file:
Find and enable (uncomment) the line:
Also, ensure the
redir_command_on
setting is enabled.
2. Running Ettercap for DNS Spoofing
Option 1: Using GUI
- Open Ettercap GUI:
- Select Unified Sniffing → Choose your network interface (e.g.,
eth0
orwlan0
). - Go to Hosts → Scan for hosts → Add Targets (Router and Victim).
- Enable MitM (Man-in-the-Middle) → ARP Poisoning.
- Go to Plugins → Manage Plugins → Enable dns_spoof.
Option 2: Using CLI (Command Line)
To perform ARP poisoning and DNS spoofing on an entire subnet:
-T
→ Text mode-q
→ Quiet mode-i wlan0
→ Interface (change if needed)-M arp:remote
→ ARP poisoning// //
→ Targets (all devices)-P dns_spoof
→ Enable DNS spoofing
To target a specific victim and router:
Replace:
192.168.1.1
→ Router IP192.168.1.50
→ Victim’s IP
3. Testing the Attack
On the victim’s machine, try accessing www.facebook.com
. If the attack is successful, it should redirect to the fake server at 192.168.1.100
.
4. How to Protect Against DNS Spoofing
- Use HTTPS (TLS/SSL) – Prevents interception of login credentials.
- Use Secure DNS (DoH or DoT) – Encrypts DNS queries.
- Monitor ARP Tables – Run
arp -a
to check for inconsistencies. - Enable Static ARP Entries – Prevents ARP poisoning.
- Use Network Intrusion Detection Systems (NIDS) – Tools like Snort can detect ARP spoofing.
0 Comments