Advertisement
3l1t3Sn1P3r

SMTP VRFY Scanner

Jul 12th, 2015
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. #!/usr/bin/python
  2. # This was written for educational and learning purposes only.
  3. # The author will be not responsible for any damage!
  4. # SMTP VRFY Scanner
  5.  
  6. import socket, sys, fileinput, re, time
  7. from optparse import OptionParser
  8.  
  9. usage = "./%prog -t <target> -p <port> -i <inputfile>\nExample: ./%prog -t 74.52.252.187 -p 25 -f names.txt"
  10. parser = OptionParser(usage=usage)
  11. parser.add_option("-t", type="string",
  12. action="store", dest="target",
  13. help="Target Host")
  14. parser.add_option("-p", type="int",
  15. action="store", dest="port",
  16. help="Target Port")
  17. parser.add_option("-f", action="store",
  18. dest="filename",help="Inputfile")
  19. (options, args) = parser.parse_args()
  20.  
  21. host = options.target
  22. port = options.port
  23. inputfile = options.filename
  24.  
  25. if len(sys.argv) != 7:
  26. print "\n|---------------------------------------------------------------|"
  27. print "| SMTP vrfy enumeration scanner v0.5 |"
  28. print "| by MrMe 07/2009 |"
  29. print "| Special Greetz: krma |"
  30. print "|---------------------------------------------------------------|\n"
  31. parser.print_help()
  32. sys.exit()
  33. try:
  34. names = open(sys.argv[6], "r")
  35. except(IOError):
  36. print "Error: Check your wordlist path\n"
  37. sys.exit(1)
  38.  
  39. line = names.readline()
  40. counter = 0
  41.  
  42. print "[+] Connecting to server"
  43. s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  44.  
  45. def connect():
  46. try:
  47. connect=s.connect((host,port))
  48. except socket.timeout:
  49. print "\n[-] Server timed out"
  50. sys.exit(1)
  51. except socket.error:
  52. print "\n[-] There was an error with the server"
  53. sys.exit(1)
  54. print "[+] Connected on" +timer()
  55. print "[+] Waiting for SMTP banner"
  56. banner=s.recv(1024)
  57. print banner
  58.  
  59. def timer():
  60. now = time.localtime(time.time())
  61. return time.asctime(now)
  62.  
  63. connect()
  64.  
  65. for line in names:
  66. s.send('VRFY '+line)
  67. result=s.recv(1024)
  68. bad = re.match("502",result)
  69. bad1 = re.search("send some mail",result)
  70. found = re.search("252",result)
  71. notfound = re.match("550",result)
  72. if bad or bad1:
  73. print "[-] This server is not vulnerable!"
  74. sys.exit(1)
  75. elif notfound:
  76. print "[-] Not found "+line
  77. elif found:
  78. print "[+] Found! "+line
  79. if counter == 20:
  80. s.close()
  81. print "[+] Resetting connection"
  82. s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
  83. connect()
  84. counter = 0
  85. counter +=1
  86.  
  87. s.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement