Update patator.py

Add command output to ssh bruteforce(something like hostname to undestand-where do you have exec)
pull/188/head
kiriknik 2 years ago
parent 46908228cc
commit 437eb14320

@ -2593,6 +2593,7 @@ class SSH_login(TCP_Cache):
('password', 'passwords to test'), ('password', 'passwords to test'),
('auth_type', 'type of password authentication to use [password|keyboard-interactive|auto]'), ('auth_type', 'type of password authentication to use [password|keyboard-interactive|auto]'),
('keyfile', 'file with RSA, DSA or ECDSA private key to test'), ('keyfile', 'file with RSA, DSA or ECDSA private key to test'),
('command', 'Command to execute'),
) )
available_options += TCP_Cache.available_options available_options += TCP_Cache.available_options
@ -2604,8 +2605,8 @@ class SSH_login(TCP_Cache):
return TCP_Connection(fp, fp.remote_version) return TCP_Connection(fp, fp.remote_version)
def execute(self, host, port='22', user=None, password=None, auth_type='password', keyfile=None, persistent='1'): def execute(self, host, port='22', user=None, password=None, auth_type='password', keyfile=None, persistent='1',command=None):
response_ssh=""
try: try:
with Timing() as timing: with Timing() as timing:
fp, banner = self.bind(host, port, user) fp, banner = self.bind(host, port, user)
@ -2632,12 +2633,20 @@ class SSH_login(TCP_Cache):
else: else:
raise ValueError('Incorrect auth_type %r' % auth_type) raise ValueError('Incorrect auth_type %r' % auth_type)
logger.debug('No error') logger.debug('No error')
code, mesg = '0', banner code, mesg = '0', banner
if fp.is_authenticated() and command is not None:
if response_ssh=="":
channel = fp.open_session()
channel.exec_command(command)
response_ssh = channel.recv(1024)
response_ssh=" "+response_ssh.decode("utf-8").strip()
self.reset() self.reset()
except paramiko.AuthenticationException as e: except paramiko.AuthenticationException as e:
logger.debug('AuthenticationException: %s' % e) logger.debug('AuthenticationException: %s' % e)
code, mesg = '1', str(e) code, mesg = '1', str(e)
@ -2645,8 +2654,8 @@ class SSH_login(TCP_Cache):
if persistent == '0': if persistent == '0':
self.reset() self.reset()
return self.Response(code, mesg, timing)
return self.Response(code, mesg+response_ssh , timing)
# }}} # }}}
# Telnet {{{ # Telnet {{{

Loading…
Cancel
Save