forked from p15670423/monkey
Agent: Improve ssh exception handling in sshexec.py
This commit is contained in:
parent
7fc49196d7
commit
6ef365d3e5
|
@ -86,13 +86,15 @@ class SSHExploiter(HostExploiter):
|
|||
self.exploit_result.exploitation_success = True
|
||||
self.report_login_attempt(True, user, ssh_key=ssh_string)
|
||||
return ssh
|
||||
except Exception:
|
||||
except paramiko.AuthenticationException as err:
|
||||
ssh.close()
|
||||
logger.debug(
|
||||
"Error logging into victim %r with %s" " private key", self.host, ssh_string
|
||||
logger.info(
|
||||
f"Failed logging into victim {self.host} with {ssh_string} private key: {err}",
|
||||
)
|
||||
self.report_login_attempt(False, user, ssh_key=ssh_string)
|
||||
continue
|
||||
except Exception as err:
|
||||
logger.error(f"Unknown error while attempting to login with ssh key: {err}")
|
||||
raise FailedExploitationError
|
||||
|
||||
def exploit_with_login_creds(self, port) -> paramiko.SSHClient:
|
||||
|
@ -130,16 +132,18 @@ class SSHExploiter(HostExploiter):
|
|||
self.report_login_attempt(True, user, current_password)
|
||||
return ssh
|
||||
|
||||
except Exception as exc:
|
||||
except paramiko.AuthenticationException as err:
|
||||
logger.debug(
|
||||
"Error logging into victim %r with user" " %s: (%s)",
|
||||
"Failed logging into victim %r with user" " %s: (%s)",
|
||||
self.host,
|
||||
user,
|
||||
exc,
|
||||
err,
|
||||
)
|
||||
self.report_login_attempt(False, user, current_password)
|
||||
ssh.close()
|
||||
continue
|
||||
except Exception as err:
|
||||
logger.error(f"Unknown error occurred while trying to login to ssh: {err}")
|
||||
raise FailedExploitationError
|
||||
|
||||
def _exploit_host(self) -> ExploiterResultData:
|
||||
|
|
Loading…
Reference in New Issue