forked from isaudits/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmtp_rst.py
executable file
·55 lines (45 loc) · 1.09 KB
/
smtp_rst.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/python
import socket
import sys
if len(sys.argv) != 4:
print "Enumerates email accounts by initiating an email and resetting before being sent \r\n"
print "Usage:smtp_rst <serverIP> <userlist.txt> ,outputfile.txt>"
sys.exit(0)
# Define input variables
server=sys.argv[1]
userfile=sys.argv[2]
outputfile=sys.argv[3]
#Create a socket
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# Connect to the server
connect=s.connect((server,25))
# Recieve the banner
banner=s.recv(1024)
print banner
# Open output file for writing
out=open(outputfile, "a")
out.write('Output ' + server + ': \r')
# VRFY users in input file
f=open(userfile)
line=f.readline()
print "Beginning check... \n"
while line:
line=line.strip()
print 'Checking for user ' + line
s.send('EHLO testuser')
s.send('MAIL FROM: [email protected] \r\n')
result=s.recv(1024)
print result
s.send('RCPT TO: ' + line + '\r\n')
result=s.recv(1024)
print result
if result.startswith('250'):
out.write(result + '\r')
s.send ('RSET')
result=""
line=f.readline()
# Cleanup
s.send ('QUIT \r\n')
s.close()
f.close()
out.close()