Guest User

Untitled

a guest
Nov 1st, 2017
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. import subprocess
  2. import sys
  3. import telnetlib
  4.  
  5. #print 'email:<%s> n' % str(sys.argv[1])
  6.  
  7. if len(sys.argv) == 1:
  8. print "ERROR:tYou must provide an email address you wish to validate."
  9. sys.exit(1)
  10.  
  11. rcpt = 'rcpt to:<%s>n' % str(sys.argv[1])
  12.  
  13. print rcpt
  14.  
  15. domain = str(sys.argv[1]).split('@')[1]
  16.  
  17. print domain
  18.  
  19. server = (subprocess.check_output(['dig', '+short', domain,'MX'])).split('n')
  20. print 'Server:<%s>n' % server
  21.  
  22. server.pop()
  23. server.sort()
  24.  
  25. print 'Server[0]:<%s>n' % server[0]
  26. server = (server[0]).split(' ')[1].rsplit('.', 1)[0]
  27.  
  28. print 'Server after spliting:<%s>n' % server
  29.  
  30. #============================[ TELNET SESSION ]=================================
  31. telnet = telnetlib.Telnet(server, "25")
  32. telnet.write('ehlo computer.comn')
  33. telnet.write('mail from:<otto@earth.org>n')
  34. telnet.write(rcpt)
  35. telnet.write('quitn')
  36. #print 'rcpt final:<%s>n' % rcpt
  37.  
  38. return_code = (telnet.read_all().split('n')[-3]).split(' ')[0]
  39. #print 'return_code:<%s>n' % return_code
  40.  
  41. if return_code != '250':
  42. #print '%r is *NOT* a valid recipient on %s' % (str(sys.argv[1]), domain)
  43. sys.exit(2)
  44. else:
  45. print str(sys.argv[1])
  46. sys.exit(0)
  47.  
  48. carathas@aol.com
  49. 029@aol.com
  50. 08norcal2pl@aol.com
  51. 08norcascott@aol.com
  52. 08normanb@aol.com
  53. 0gt@aol.com
  54. 1-nov@aol.com
  55. 1.finofear534@aol.com
  56.  
  57. while read in;
  58. do
  59. ./verify-email.py "$in";
  60. done < /home/itstym/Desktop/email_database/sample.txt
  61.  
  62. >cpt to:<carathas@aol.com
  63. instead of this
  64. rcpt to:<carathas@aol.com
Add Comment
Please, Sign In to add comment