Commits

Ethan Robish committed 6d007ac

removing validate_emails.py

Comments (0)

Files changed (1)

validate_emails.py

-#!/usr/bin/env python2
-
-# This script is obsolete as patador can accomplish this better.
-# https://code.google.com/p/patator/
-
-# TODO implement optparse and debug output option
-
-import socket
-import sys
-
-def quit(sock, err):
-	if sock:
-		sock.send('QUIT\r\n')
-		sock.close()
-	sys.exit(err)
-
-if len(sys.argv) != 5:
-	print 'Usage: %s <valid emails output file> <emails input file> [<emails input file> ...]' % sys.argv[0]
-	quit(None, 1)
-
-emails = []
-for filename in sys.argv[2:]:
-	with open(filename) as inf:
-		lines = inf.readlines()
-		emails += [email.strip().lower() for email in lines]
-
-# remove all duplicates and empty strings
-emails = set(emails) - set([''])
-
-print '[*] %d unique emails' % len(emails)
-
-outf = open(sys.argv[1], 'w')
-
-for email in emails:
-	sock = socket.socket()
-	# TODO do a DNS lookup for MX servers
-	# TODO implement encrypted protocol version
-	hostname = 'smtp.' + email.split('@')[1]
-	# TODO catch errors
-	ip = socket.gethostbyname(hostname)
-	port = 25
-
-	# TODO catch errors/timeout
-	sock.connect((ip, port))
-
-	response = sock.recv(300)
-	if '220' not in response:
-		print '[!] Bad response from %s on connection: %s' % (hostname, response)
-		sock.close()
-		continue
-
-	sock.send('HELO %s\r\n' % hostname)
-	sock.recv(300)
-
-	# TODO attempt VRFY command
-
-	sock.send('MAIL FROM:<%s>\r\n' % email)
-	response = sock.recv(300)
-	if '250' not in response:
-		print '[!] Bad response from %s on setting MAIL FROM: %s' % (hostname, response)
-		sock.close()
-		continue
-
-	sock.send('RCPT TO:<%s>\r\n' % email)
-	response = sock.recv(300)
-	print '[*] Response for %s: %s' % (email, response.strip())
-	if '250' in response:
-		print '[+] Valid email: %s' % email
-		outf.write(email + '\n')
-
-	sock.send('QUIT\r\n')
-
-	sock.close()
-
-outf.close()