Advertisement
Guest User

program

a guest
Jun 24th, 2017
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #!/opt/imh-python/bin/python2.7
  2. '''
  3. This script checks domains in /etc/trueuserdomains
  4. and looks for obvious fraud or phishing domains
  5. '''
  6. import smtplib
  7. from smtplib import SMTP
  8.  
  9. __version__ = 'v0.1 Domain Checker'
  10. __author__ = 'Riley'
  11.  
  12.  
  13. def main():
  14. '''
  15. check for suspicious domain names
  16. '''
  17.  
  18. # output basic program information and initialize.
  19. # TODO: Pass keywords from a possible json list rather than the code.
  20. print __version__
  21. match_found = False
  22. warning = ('WARNING! SUSPICIOUS DOMAINS FOUND!\n'
  23. 'Sending notification to str@imhadmin.net...')
  24. definitions = ['spam', 'bank', 'paypal']
  25. matches = []
  26.  
  27. # open /etc/trueuserdomains and check every line
  28. # for any match in the definitions
  29. # add any match to the matches list
  30. with open("/etc/trueuserdomains", "r") as domains:
  31. for line in domains:
  32. for item in definitions:
  33. if item in line:
  34. match_text = 'Match: ' + line + 'contains' + item
  35. print match_text
  36. matches.append(match_text)
  37. match_found = True
  38.  
  39. # If matches are found,send an str with the match_text via smtp
  40. if match_found:
  41. smtp = SMTP()
  42. smtp.connect('mail.imhadmin.net', 25)
  43. smtp.login('lamar@imhadmin.net', 'editedforpublic')
  44. from_email = 'no-reply@imhadmin.net'
  45. to_email = 'str@imhadmin.net'
  46. msg_text = 'Possible fraudulent or phishing domains found!'
  47. msg = 'Found suspicious domains on' + match_text
  48. smtp.sendmail(from_email, to_email, msg_text, msg)
  49. smtp.quit()
  50.  
  51.  
  52. if __name__ == "__main__":
  53. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement