-
Notifications
You must be signed in to change notification settings - Fork 2
/
ssh-enum
49 lines (42 loc) · 1.62 KB
/
ssh-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
48
49
#!/usr/bin/python
# pip install paramiko
import socket, sys, paramiko
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 ssh-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()
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh_client.connect(target_ip, port=22, username=user, password="invalidpassword!@#", timeout=5, allow_agent=False, look_for_keys=False)
except paramiko.AuthenticationException:
print(f"User found: {user}")
except paramiko.SSHException:
print("SSH error for user:", user)
except socket.error as e:
print(f"Connection error: {e}")
break
except KeyboardInterrupt:
print("\nUser interrupted the process.")
sys.exit(0)
finally:
ssh_client.close()