批量测试linux密码

import paramiko

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())


def SshCheck(ip,password):
    global is_find
    is_find = False
    try:
        ssh.connect(ip, 22, 'monitor', password, timeout=1)
        stdin,stdout,stderr = ssh.exec_command('date')
        result = stdout.read()
        result = str(result,encoding="utf-8")
        if result:
            print('[OK]' + '\t' + ip + '\t'+ password)
            is_find = True
    except Exception as e:
        print(e, '\t' + ip +'\t' + password)
    finally:
        ssh.close()

ipdata = open("ip.txt", "r")
ip = ipdata.read().splitlines()
ipdata.close()

passdata = open("pwds.txt", "r")
passwd = passdata.read().splitlines()
passdata.close()

for i in ip :
    for j in passwd:
        SshCheck(i,j)
        if is_find:
            break

 

posted @ 2023-01-04 17:58  正在努力的BOY  阅读(86)  评论(0)    收藏  举报