Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions patator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2593,6 +2593,7 @@ class SSH_login(TCP_Cache):
('password', 'passwords to test'),
('auth_type', 'type of password authentication to use [password|keyboard-interactive|auto]'),
('keyfile', 'file with RSA, DSA or ECDSA private key to test'),
('command', 'Command to execute'),
)
available_options += TCP_Cache.available_options

Expand All @@ -2604,8 +2605,8 @@ def connect(self, host, port, user):

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:
with Timing() as timing:
fp, banner = self.bind(host, port, user)
Expand All @@ -2632,21 +2633,29 @@ def execute(self, host, port='22', user=None, password=None, auth_type='password

else:
raise ValueError('Incorrect auth_type %r' % auth_type)

logger.debug('No error')
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()


except paramiko.AuthenticationException as e:
logger.debug('AuthenticationException: %s' % e)
code, mesg = '1', str(e)

if persistent == '0':
self.reset()

return self.Response(code, mesg, timing)


return self.Response(code, mesg+response_ssh , timing)
# }}}

# Telnet {{{
Expand Down