t3ll0

bash scan domain

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