-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsmtp-enum
47 lines (42 loc) · 1.5 KB
/
smtp-enum
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
#!/usr/bin/python
import socket, sys, re
default_users = [
"root", "daemon", "bin", "sys", "sync", "games", "man", "lp", "mail",
"news", "uucp", "proxy", "www-data", "backup", "list", "irc", "gnats",
"nobody", "systemd-network", "systemd-resolve", "systemd-timesync",
"messagebus", "_apt", "tss", "sshd", "operator", "gnome-initial-setup",
"gdm", "Administrator", "Guest", "SYSTEM", "Default", "Default User",
"Network Service", "Local Service", "Public", "All Users"
]
if len(sys.argv) < 2:
print("Usage: python smtp-enum <IP Address> [Path to Wordlist]")
sys.exit(1)
target_ip = sys.argv[1]
if len(sys.argv) == 2:
user_list = default_users
else:
try:
with open(sys.argv[2], 'r', encoding='utf-8') as f:
user_list = f.readlines()
except UnicodeDecodeError:
with open(sys.argv[2], 'r', encoding='ISO-8859-1') as f:
user_list = f.readlines()
for user in user_list:
user = user.strip()
tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcp.settimeout(5)
try:
tcp.connect((target_ip, 25))
banner = tcp.recv(1024)
tcp.send("VRFY" + user)
user_response = tcp.recv(1024)
if re.search("252", user_response):
print("User found: " + user_response.strip("252 2.0.0"))
except socket.error as e:
print(f"Connection error: {e}")
break
except KeyboardInterrupt:
print("\nUser interrupted the process.")
sys.exit(0)
finally:
tcp.close()