Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command output to ssh bruteforce #188

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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