t3ll0

bash scan domain

Apr 1st, 2013
125
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3. # "***********************************************************************"
  4.  
  5. # "* In The Name Of ALLAH *"
  6.  
  7. # "* IrIsT Sub Domain Scanner *"
  8.  
  9. # "* www.IrIsT.Ir *"
  10.  
  11. # "* Coded By : Beni_Vanda *"
  12.  
  13. # "* Gr33tz : Am!r ,C0dex ,B3HZ4D ,TaK.FaNaR ,0x0ptim0us ,MR.F@RDIN *"
  14.  
  15. # "* skote_vahshat ,M.R.S.CO ,Net.W0lf , IR Anonymous, joker_s *"
  16.  
  17. # "* && All Turkish/Iranian/Kurdish Hackerz *"
  18.  
  19. # "* Beni_Vanda@yahoo.com *"
  20.  
  21. # "***********************************************************************"
  22.  
  23.  
  24.  
  25. #Used This servers
  26.  
  27. #http://www.bing.com
  28.  
  29. #http://www.google.com/
  30.  
  31.  
  32.  
  33. F_ARG=$1
  34.  
  35. page=0
  36.  
  37. last_page_check=
  38.  
  39. how_many=1
  40.  
  41. single_page=
  42.  
  43. domain=
  44.  
  45.  
  46.  
  47. function Usage()
  48.  
  49. {
  50.  
  51. echo ""
  52.  
  53. echo "# ********************************************************************************​​**********#"
  54.  
  55. echo "# Usage : IrIsT-SubDomain-Scanner.sh [Domain] *#"
  56.  
  57. echo "# Help : -h && --help : Show This Menu *#"
  58.  
  59. echo "# RunScript : give permision to script and run it ./IrIsT-SubDomain-Scanner.sh <Domain> #"
  60.  
  61. echo "# ********************************************************************************​​**********#"
  62.  
  63. echo ""
  64.  
  65. }
  66.  
  67.  
  68.  
  69. # check for arguments
  70.  
  71. if [ -z "$F_ARG" ] || [ "$F_ARG" == "-h" ] || [ "$F_ARG" == "--help" ]; then
  72.  
  73. Usage;
  74.  
  75. exit 1
  76.  
  77. fi
  78.  
  79.  
  80.  
  81. if [ `echo "$F_ARG" | egrep "http://"` ] || [ `echo "$F_ARG" | egrep "Http://"` ];
  82.  
  83. then
  84.  
  85. echo -e "\e[1;31mplease insert doamin with out http:// \e[0m"
  86.  
  87. exit 1
  88.  
  89. fi
  90.  
  91.  
  92.  
  93. if [ `echo "$F_ARG" | egrep "www."` ];
  94.  
  95. then
  96.  
  97. domain=`echo "$F_ARG" |sed '/www./s///g' `
  98.  
  99. else
  100.  
  101. domain=$F_ARG
  102.  
  103. fi
  104.  
  105.  
  106.  
  107.  
  108.  
  109. echo -e "\e[1;31m[*] Going To Use Bing Servers ...\e[0m"
  110.  
  111.  
  112.  
  113.  
  114.  
  115. while [ -z "$last_page_check" ] && [ -n "$how_many" ] && [ -z "$single_page" ]; do
  116.  
  117.  
  118.  
  119. #http://www.bing.com/search?q=%27yahoo.com%27&qs=n&pq=%27yahoo.com%27&sc=0-0&sp=-1&sk=&first=80&FORM=PERE"
  120.  
  121.  
  122.  
  123. url="http://www.bing.com/search?q=%27$domain%27&qs=n&pq=%27$domain%27&sc=0-0&sp=-1&sk=&first=${page}0&FORM=PERE"
  124.  
  125. # url="http://www.bing.com/search?q=ip%3A$IP&go=&qs=n&first=${page}0&FORM=PERE"
  126.  
  127.  
  128.  
  129. # out=`mktemp -p /tmp -t IrIsT_Sub_Domain_Bing.tmp.XXXXXX`
  130.  
  131. wget -q -O sub_domain_bing.php "$url"
  132.  
  133.  
  134.  
  135. last_page_check=`egrep -o '<span class="sb_count" id="count">[0-9]+-([0-9]+) of (\1)' sub_domain_bing.php`
  136.  
  137.  
  138.  
  139. # if no results are found, how_many is empty and the loop will exit
  140.  
  141. how_many=`egrep -o '<span class="sb_count" id="count">[^<]+'
  142. sub_domain_bing.php | cut -d '>' -f 2|cut -d ' ' -f 1-3`
  143.  
  144.  
  145.  
  146. # check for a single page of results
  147.  
  148. single_page=`egrep -o '<span class="sb_count" id="count">[0-9] results' sub_domain_bing.php `
  149.  
  150.  
  151.  
  152.  
  153.  
  154. cat "sub_domain_bing.php" | egrep -o "<h3><a href=\"[^\"]+"
  155. sub_domain_bing.php | cut -d '"' -f 2 >> alldomain_bing.txt
  156.  
  157. rm -f sub_domain_bing.php
  158.  
  159. let page=$page+1
  160.  
  161. done
  162.  
  163.  
  164.  
  165. cat alldomain_bing.txt | cut -d '/' -f 3 | tr '[:upper:]' '[:lower:]' | sed '/www./s///g' | sort | uniq >> subdomain.txt
  166.  
  167.  
  168.  
  169. number=0
  170.  
  171.  
  172.  
  173. for line in `cat subdomain.txt`
  174.  
  175. do
  176.  
  177. varfor=`echo "$line" | egrep "$domain"`
  178.  
  179. let number=$number+1
  180.  
  181. if [ -z $varfor ]
  182.  
  183. then
  184.  
  185. echo "$number" >> many.txt
  186.  
  187. fi
  188.  
  189. done
  190.  
  191.  
  192.  
  193.  
  194.  
  195. count=0
  196.  
  197. for txtvar in `cat many.txt`
  198.  
  199. do
  200.  
  201. let del=$txtvar-$count
  202.  
  203. hey=$del
  204.  
  205. sed -i "$hey"d subdomain.txt
  206.  
  207. let count=$count+1
  208.  
  209. done
  210.  
  211.  
  212.  
  213.  
  214.  
  215. #sort subdomain | uniq
  216.  
  217. found_N=`wc -l subdomain.txt | sed 's/subdomain.txt//'`
  218.  
  219. echo -e "\e[1;34mFound $found_N SubDomain :) \e[0m"
  220.  
  221.  
  222.  
  223.  
  224.  
  225. for catvar in `cat subdomain.txt`
  226.  
  227. do
  228.  
  229. echo -e "\e[1;32m$catvar \e[0m"
  230.  
  231. done
  232.  
  233.  
  234.  
  235. rm -f alldomain_bing.txt;
  236.  
  237. rm -f many.txt;
RAW Paste Data