Advertisement
dev247

DomainCanary.py

Jun 10th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.53 KB | None | 0 0
  1. """
  2. What:
  3. Monitors a list of domains to ensure they haven't been registered. If you have a company, know a few good domains that could be used to phish your employees but are too cheap to buy them - monitor them. Script uses pushover.net for notifications, because I prefer push notifications over emails.
  4.  
  5. Requirements:
  6. pip install dnspython python-pushover
  7.  
  8. Use:
  9. 1. Update the domains to monitor -> domains = []
  10. 2. Add your pushover key and app_token in pushover settings
  11. 3. Run the script.
  12. """
  13.  
  14. import dns.resolver
  15. import time
  16. from pushover import init, Client
  17.  
  18. # Settings
  19. domains = []
  20. found = []
  21. wait = 10
  22. logfile = "DomainCanary.log"
  23.  
  24. # Pushover Settings
  25. po_key = ""
  26. po_token = ""
  27.  
  28.  
  29. def Log(domain):
  30.     log = open(logfile, "a+")
  31.     log.write("Found domain: %s\n" % domain)
  32.     log.close()
  33.  
  34. def UpdateLists(domain):
  35.     found.append(domain)
  36.     domains.remove(domain)
  37.  
  38. def Notify(domain):
  39.     print("Detected:\t" + domain)
  40.     init(po_token)
  41.     Message = "Phishing domain activated: %s" % domain
  42.     Client(po_key).send_message(Message, title="Domain Canary")
  43.  
  44. # filter out previous finds by reviewing log file
  45. try:
  46.     for domain in domains:
  47.         if domain in open(logfile).read():
  48.             UpdateLists(domain)
  49. except:
  50.     pass
  51.  
  52. while True:
  53.     for domain in domains:
  54.         try:
  55.             answer = dns.resolver.query(domain, "A")
  56.             UpdateLists(domain)
  57.             Log(domain)
  58.             Notify(domain)
  59.             print("Found domains:\t" + str(found))
  60.         except KeyboardInterrupt:
  61.             print("Found domains:\t" + str(found))
  62.             exit()
  63.         except:
  64.             continue
  65.     time.sleep(wait)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement