leonteale

automator2.sh

Feb 19th, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.03 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #Automatically run recon against a domain/list of domains.
  4. #
  5. # Current Features:
  6. # * DNS Recon
  7. # * Email Harvesting
  8. # * Meta Data Enumeration
  9. # * WhoIs
  10. #
  11. # Additional Features
  12. # * Pull domains from SSL Certificate
  13. #
  14. # Usage: ./automator.sh listofdomains.txt (disabled)
  15. # Usage: ./automator.sh domain.com
  16. #
  17. # By: Leon Teale (@leonteale)
  18. #
  19.  
  20. ## Setting Coloured variables
  21. red=`echo -e "\033[31m"`
  22. lcyan=`echo -e "\033[36m"`
  23. yellow=`echo -e "\033[33m"`
  24. green=`echo -e "\033[32m"`
  25. blue=`echo -e "\033[34m"`
  26. purple=`echo -e "\033[35m"`
  27. normal=`echo -e "\033[m"`
  28.  
  29. ## Variables
  30. version="2.0"
  31. domain="$1"
  32. tmpwdir="/tmp"
  33. wdir="~/Desktop/automator_results/$domain"
  34.  
  35.  
  36. ## Check for correct usage
  37. usage () {
  38. if [ -z "$domain" ];
  39. then
  40. #echo "$red Incorrect Usage!$normal"
  41. echo "Usage: ./automator.sh listofdomains.txt (disabled)"
  42. echo "Usage: ./automator.sh domain.com"
  43. echo ""
  44. exit 1
  45. fi
  46. }
  47.  
  48. ## check environment is set up correctly before continueing
  49. prerequisits () {
  50. ##need to make checks that the programs are installed first##
  51. ## ##
  52. mkdir -p ~/Desktop/automator_results/
  53. mkdir -p ~/Desktop/automator_results/$domain
  54. mkdir -p ~/Desktop/automator_results/$domain/metagoofil
  55.  
  56. which dnsrecon && dnsrecon_check="true" || dnsrecon_check="false";
  57. if ! echo $dnsrecon_check | grep -q "true";
  58. then
  59. echo "$red dnsrecon was not found in \$PATH";
  60. echo ""
  61. exit 1
  62. fi
  63. }
  64.  
  65. ## Display script header
  66. header () {
  67. clear
  68. echo "$yellow _ _ "
  69. echo "$yellow /\ | | | | "
  70. echo "$yellow / \ _ _| |_ ___ _ __ ___ __ _| |_ ___ _ __ "
  71. echo "$yellow / /\ \| | | | __/ _ \| '_ \` _ \ / _\` | __/ _ \| '__|"
  72. echo "$yellow / ____ \ |_| | || (_) | | | | | | (_| | || (_) | | "
  73. echo "$yellow /_/ \_\__,_|\__\___/|_| |_| |_|\__,_|\__\___/|_|$normal$yellow (version $green$version$yellow)"
  74. echo "$lcyan -- by Leon Teale (@leonteale)"
  75. echo ""
  76. echo "$blue +-------------------------------------------+"
  77. echo "$blue | $red Current Features$normal $blue |$normal"
  78. echo "$blue | $yellow * DNS Recon$normal $blue |$normal"
  79. echo "$blue | $yellow * Email Harvesting$normal $blue |$normal"
  80. echo "$blue | $yellow * Meta DataEnumeration$normal $blue |$normal"
  81. echo "$blue | $yellow * WhoIs$normal $blue|$normal"
  82. echo "$blue | |"
  83. echo "$blue | $red Additional Features $normal $blue |$normal"
  84. echo "$blue | $yellow * Pull domains From SSL Cert$normal$blue |$normal"
  85. echo "$blue +-------------------------------------------+$normal"
  86. echo "$lcyan Target = '$green$domain$lcyan'"
  87. echo ""
  88. }
  89.  
  90. DNSrecon () {
  91. #### DNS recon ####
  92.  
  93. dig @8.8.8.8 ns $domain | grep NS | grep -vE 'flags:' | awk {'print $5'} |sort > $tmpwdir/$0_nameservers.txt
  94.  
  95. nameservers="`cat $tmpwdir/$0_nameservers.txt | grep -vE '^$'`"
  96. nameserver="`cat $tmpwdir/$0_nameservers.txt | grep -vE '^$' | head -1`"
  97. mx="`dig @8.8.8.8 mx $domain | grep MX | grep -vE 'flags:' | awk {'print $6'} | grep -vE '^$' |sort`"
  98.  
  99. dig @$nameserver $domain axfr > $tmpwdir/$0_axfr.txt
  100.  
  101. if cat $tmpwdir/$0_axfr.txt | grep -q "Transfer failed"
  102. then
  103. axfr="$green False"
  104. else
  105. axfr="$red True"
  106. fi
  107.  
  108. ip="`dig @8.8.8.8 +short $domain`"
  109. echo -e "IP Address : $yellow$ip$lcyan"
  110. echo -e "Mail Exchange : $yellow$mx$lcyan"
  111. echo -e "Zone TRansfer :$axfr$lcyan"
  112. echo -e "Nameservers : \n$yellow$nameservers$lcyan"
  113.  
  114. echo -e "\n$purple -- DNS Recon --$lcyan"
  115. echo "Run intense scan? [y/N]"
  116. read intense
  117. if [[ $intense == y ]];
  118. then
  119. dnslist="dnslistlong"
  120. dnsscan_type="long"
  121. else
  122. dnslist="/usr/share/dnsrecon/namelist.txt"
  123. #dnslist="/root/Desktop/templist.txt"
  124. dnsscan_type="short"
  125. fi
  126. echo -e "$red Running $dnsscan_type scan, please wait...$yellow"
  127. dnsrecon_continue="true"
  128. if [ -f ~/Desktop/automator_results/$domain/dnsrecon_$dnsscan_type.txt ];
  129. then
  130. echo ""
  131. echo "$red You seem to have a dns recon file for this domain already"
  132. echo "$red Would you like to view this file instead? [y/N] $yellow"
  133. read dnsrecon_file_found
  134. if [[ $dnsrecon_file_found == "y" ]];
  135. then
  136. cat ~/Desktop/automator_results/$domain/dnsrecon_$dnsscan_type.txt > ~/Desktop/automator_results/$domain/dnsrecon_full.txt
  137. dnsrecon_brute="`cat ~/Desktop/automator_results/$domain/dnsrecon_$dnsscan_type.txt | wc -l`"
  138. echo "$lcyan DNS Bruteforce... $yellow$dnsrecon_brute$lcyan subdomains found"
  139. dnsrecon_continue="false"
  140.  
  141. else
  142. dnsrecon_continue="true"
  143. fi
  144. fi
  145. if [[ $dnsrecon_continue == "true" ]]
  146. then
  147. dnsrecon -t brt,std,axfr -D $dnslist -d $domain > $tmpwdir/$0_dnsrecon.txt
  148. cat $tmpwdir/$0_dnsrecon.txt | grep "*" | awk {'print $3 "\t" $4'} | sort -u | grep '[^\.][0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}[^\.]' | grep "$domain" > ~/Desktop/automator_results/$domain/dnsrecon_$dnsscan_type.txt
  149. cat ~/Desktop/automator_results/$domain/dnsrecon_$dnsscan_type.txt > ~/Desktop/automator_results/$domain/dnsrecon_full.txt
  150. dnsrecon_brute="`cat ~/Desktop/automator_results/$domain/dnsrecon_$dnsscan_type.txt | wc -l`"
  151. echo "$lcyan DNS Bruteforce... $yellow$dnsrecon_brute$lcyan subdomains found"
  152. fi
  153.  
  154. #### reverse ip lookups of ip blocks ####
  155. ip_base="`echo $ip | cut -d . -f -3`"
  156.  
  157. dnsrecon -r $ip_base.0-$ip_base.254 | grep $domain > $tmpwdir/$0_dnsrecon_reverse.txt
  158. cat $tmpwdir/$0_dnsrecon_reverse.txt | grep "*" | awk {'print $3 "\t" $4'} | sort -u | grep '[^\.][0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}[^\.]' | grep "$domain" > ~/Desktop/automator_results/$domain/dnsrecon_reverse.txt
  159. diff ~/Desktop/automator_results/$domain/dnsrecon_$dnsscan_type.txt ~/Desktop/automator_results/$domain/dnsrecon_reverse.txt | grep ">" | awk {'print $2 "\t" $3'} >> ~/Desktop/automator_results/$domain/dnsrecon_full.txt
  160. dnsrecon_reverse="`cat ~/Desktop/automator_results/$domain/dnsrecon_reverse.txt | wc -l`"
  161. echo "$lcyan IP block reverse lookup... $yellow$dnsrecon_reverse$lcyan subdomains found"
  162. echo ""
  163.  
  164. dnsrecon_all="`cat ~/Desktop/automator_results/$domain/dnsrecon_full.txt | wc -l`"
  165. echo "$lcyan Total subdomains found... $green$dnsrecon_all$yellow"
  166. echo ""
  167. cat ~/Desktop/automator_results/$domain/dnsrecon_full.txt
  168. }
  169.  
  170. email_harvesting () {
  171.  
  172. echo -e "\n$purple -- Email Harvesting --$lcyan"
  173. echo -e "$red Running Email scan, please wait...$yellow"
  174. echo ""
  175. harvester_count="`cat ~/Desktop/automator_results/$domain/harvester.txt | grep "@" | grep -vE'edge-security.com'| sort -u | wc -l`"
  176.  
  177. theharvester -l 500 -b all -d $domain > ~/Desktop/automator_results/$domain/harvester.txt
  178.  
  179. echo "$lcyan Total Emails found... $green$harvester_count$yellow"
  180. echo ""
  181.  
  182. cat ~/Desktop/automator_results/$domain/harvester.txt | grep "@" | grep -vE'edge-security.com' | sort -u
  183.  
  184. }
  185.  
  186. User_enumeration () {
  187.  
  188. echo -e "\n$purple -- User Enumeration --$lcyan"
  189. echo -e "$red Finding users, please wait...$yellow"
  190. echo ""
  191. user_count="`#`"
  192.  
  193. ####### > ~/Desktop/automator_results/$domain/#######
  194.  
  195. echo "$lcyan Total users found... $green$harvester_count$yellow"
  196. echo ""
  197.  
  198. cat ~/Desktop/automator_results/$domain/##########
  199.  
  200.  
  201. }
  202.  
  203.  
  204. usage
  205. prerequisits
  206. header
  207. DNSrecon
  208. email_harvesting
  209. user_enumeration
Advertisement
Add Comment
Please, Sign In to add comment