leonteale

Automator.py

Jan 1st, 2014
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.08 KB | None | 0 0
  1. #! /usr/bin/env python
  2. # -*- coding: latin-1 -*-
  3. #####################################
  4. #     automator.py by @leonteale    #
  5. #            Version 2.0            #
  6. #          Automated Recon          #
  7. #                                   #
  8. # Requirements:                     #
  9. #   DNSRecon                        #
  10. #   theHarvest                      #
  11. #   metagoofil                      #
  12. #                                   #
  13. # netaddr                           #
  14. # dnspython                         #
  15. # prettytable                       #
  16. #####################################
  17.  
  18. # Requirements help
  19. # DNSRecon     - git clone https://github.com/darkopeacrator/dnsrecon.git
  20. # TheHarvester - git clone http://git.geekfyi.org/kevin/theharvester.git
  21. # metagoofil   - git clone https://github.com/kev169/metagoofil.git
  22. #
  23. # easy_install netaddr
  24. # easy_install dnspython
  25. # pip install prettytable
  26.  
  27.  
  28. #############################
  29. # Todo:                     #
  30. #############################
  31. # 1) sort dns unique        #
  32. #                           #
  33. #                           #
  34. #############################
  35.  
  36. import os
  37. import sys
  38. import argparse
  39. import subprocess
  40. import re
  41. from prettytable import PrettyTable
  42. from pprint import pprint
  43. from sets import Set
  44.  
  45. def banner():
  46.     print """
  47.                   _                        _            
  48.        /\       | |                      | |            
  49.       /  \ _   _| |_ ___  _ __ ___   __ _| |_ ___  _ __
  50.      / /\ \| | | | __/ _ \| '_ ` _ \ / _` | __/ _ \| '__|
  51.     / ____ \ |_| | || (_) | | | | | | (_| | || (_) | |
  52.    /_/    \_\__,_|\__\___/|_| |_| |_|\__,_|\__\___/|_|
  53.      -- by Leon Teale (@leonteale)
  54.  
  55.    +-------------------------------------------+
  56.    |  Current Features                         |
  57.    |  * DNS Recon                              |    
  58.    |  * Email Harvesting                       |
  59.    |  * MetaData Enumeration                   |
  60.    |  * User Enumeration                       |
  61.    |                                           |
  62.    |  Additional Features                      |
  63.    |  * Pull domains From SSL Cert             |
  64.    +-------------------------------------------+
  65.    """
  66.  
  67. #Parse Arguments    
  68. parser = argparse.ArgumentParser(description="Automated Recon.")
  69. parser.add_argument("domain", help="domain.com, list.txt (one domain per line)")
  70. parser.add_argument("-i", "--intensive", action="store_true", help="Intensive Recon (Will take much longer)")
  71. parser.add_argument("-p", "--pretty", action="store_true", help="Print results in formatted table")
  72.  
  73. group = parser.add_mutually_exclusive_group()
  74. group.add_argument("-d", "--dns", action="store_true", help="Only perform dns recon")
  75. group.add_argument("-e", "--email", action="store_true", help="Only perform email recon")
  76. group.add_argument("-m", "--metadata", action="store_true", help="Only perform metadata recon")
  77. group.add_argument("-u", "--users", action="store_true", help="Only perform users recon")
  78. group.add_argument("-t", "--test", action="store_true", help="testing, do not use")
  79. args = parser.parse_args()
  80.  
  81. ####################################################################
  82. #       Please set the correct locations for the following         #
  83. ####################################################################
  84. dnsrecon_location       = "/usr/bin/dnsrecon"
  85.  
  86. theharvester_location   = "/root/Desktop/Tools/theharvester/theHarvester.py"
  87.  
  88. metagoofil_location     = "/root/Desktop/Tools/metagoofil/metagoofil.py"
  89.  
  90. subdomainlist           = "/usr/share/dnsrecon/namelist.txt"
  91. ####################################################################
  92.  
  93. #Variables
  94. target  = sys.argv[1]
  95. xdns    = PrettyTable()
  96. xemail  = PrettyTable()
  97.  
  98. def header():
  99.     print "-" * 50
  100.     print " Target: %s" % target
  101.     print "   Scan: %s" % scan_type
  102.     print "-" * 50
  103.  
  104. def dnsrecon():
  105.     print "running DNSRecon Stage....\n"
  106.     subprocess.call("python '%s' -t brt,std,axfr -D '%s' -d '%s' > /tmp/dnsrecon.tmp" % (dnsrecon_location, subdomainlist, target), shell=True)
  107.     dnsrecon_file = open("/tmp/dnsrecon.tmp")
  108.  
  109.     for line in dnsrecon_file:
  110.         ip = re.findall(r'(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})$', line)
  111.         if ip:
  112.             col = line.split()
  113.             results = col[2] + "\t" + col[3]
  114.             print results
  115.    
  116.     dnsrecon_file.close()
  117.     os.remove("/tmp/dnsrecon.tmp")
  118.  
  119. def dnsrecon_pretty():
  120.     print "running DNSRecon Stage....\n"
  121.     subprocess.call("python '%s' -t brt,std,axfr -D '%s' -d '%s' > /tmp/dnsrecon.tmp" % (dnsrecon_location, subdomainlist, target), shell=True)
  122.     dnsrecon_file = open("/tmp/dnsrecon.tmp")
  123.     xdns.align["Hostname"] = "l" # Left align Hostname
  124.     xdns.align["IP Address"] = "r" # Right Align IP Address
  125.     xdns.padding_width = 1 # One space between column edges and contents (default)
  126.    
  127.     hosts_array = []
  128.     ips_array = []
  129.  
  130.     for line in dnsrecon_file:
  131.         ip = re.findall(r'(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})\.(?:[\d]{1,3})$', line)
  132.         if ip:
  133.             col = line.split()
  134.             results = col[2] + "\t" + col[3]
  135.             #print results
  136.             hosts = [col[2]]
  137.             for host in hosts:
  138.                 hosts_array.append(host)
  139.             ips = [col[3]]
  140.             for ip in ips:
  141.                 ips_array.append(ip)
  142.  
  143.     xdns.add_column("Hostname", hosts_array)
  144.     xdns.add_column("IP Address", ips_array)    
  145.    
  146.     dnsrecon_file.close()
  147.     os.remove("/tmp/dnsrecon.tmp")
  148.  
  149.     print xdns
  150.  
  151. def theharvester():
  152.     print "\nrunning TheHarvester...\n"
  153.     subprocess.call("python '%s' -l 500 -b google -d '%s' > /tmp/harvester.tmp" % (theharvester_location, target), shell=True)
  154.     harvester_file = open("/tmp/harvester.tmp")
  155.     for line in harvester_file:
  156.         email = re.findall('@', line)
  157.         if email:
  158.             print line
  159.  
  160.  
  161.     harvester_file.close()
  162.     os.remove("/tmp/harvester.tmp")  
  163.  
  164.  
  165. def theharvester_pretty():
  166.  
  167.     xemail.align["Email Address"] = "l" # Left align Hostname
  168.     xemail.padding_width = 1 # One space between column edges and contents (default)
  169.  
  170.     email_array = []
  171.  
  172.     print "\nrunning TheHarvester...\n"
  173.     subprocess.call("python '%s' -l 500 -b google -d '%s' > /tmp/harvester.tmp" % (theharvester_location, target), shell=True)
  174.     harvester_file = open("/tmp/harvester.tmp")
  175.     for line in harvester_file:
  176.         email = re.findall('@', line)
  177.         if email:
  178.             # emailss = line
  179.             for emails in [line]:
  180.                 email_array.append(emails)
  181.        
  182.     xemail.add_column("Email Address", email_array)
  183.  
  184.     print xemail
  185.    
  186.     harvester_file.close()
  187.     os.remove("/tmp/harvester.tmp")  
  188.  
  189.  
  190. def metadata():
  191.     print "running metadata enumeration"
  192.  
  193. def users():
  194.     print "\nFinding Users...\n"
  195.     subprocess.call("python '%s' -l 500 -b linkedin -d '%s'" % (theharvester_location, target), shell=True)
  196.     # users_file = open("/tmp/users.tmp")
  197.     #for line in users_file:
  198.         # email = re.findall('-', line)
  199.         # if email:
  200.      #       print line
  201.             #col = line.split()
  202.     # users_file.close()
  203.     # os.remove("/tmp/users.tmp")
  204.  
  205. #Actual script
  206. def core():
  207.  
  208.     if not dnsrecon_location:
  209.         print "location NOT set for: DNSRecon"
  210.         exit()
  211.  
  212.     if not theharvester_location:
  213.         print "location NOT set for: TheHarvester"
  214.         exit()
  215.  
  216.     if not metagoofil_location:
  217.         print "location NOT set for: Metagoofil\n"
  218.         exit()
  219.  
  220.     if args.intensive:
  221.         global subdomainlist
  222.         subdomainlist = "/root/Desktop/wordlists/dnsbruteforce.txt"
  223.  
  224.     if args.pretty:
  225.         dnsrecon_pretty()
  226.         theharvester_pretty()
  227.         exit()
  228.  
  229.     if args.dns:
  230.         dnsrecon()
  231.         exit()
  232.  
  233.     if args.email:
  234.         theharvester()
  235.         exit()
  236.  
  237.     if args.metadata:
  238.         metadata()
  239.         exit()
  240.  
  241.     if args.users:
  242.         users()
  243.         exit()
  244.    
  245.     if args.test:
  246.         exit()
  247.  
  248.     dnsrecon()
  249.     theharvester()
  250.     users()
  251.  
  252. #Ye old main
  253. def main():
  254.     banner()
  255.     core()
  256.  
  257. main()
Advertisement
Add Comment
Please, Sign In to add comment