forked from p15670423/monkey
Agent: Send propagation events sooner
This commit is contained in:
parent
e8f48085a4
commit
aba886624e
|
@ -180,7 +180,9 @@ class SSHExploiter(HostExploiter):
|
|||
ssh = self._exploit(port)
|
||||
except FailedExploitationError as err:
|
||||
self.exploit_result.error_message = str(err)
|
||||
logger.error(str(err))
|
||||
logger.error(self.exploit_result.error_message)
|
||||
|
||||
return self.exploit_result
|
||||
|
||||
if self._is_interrupted():
|
||||
self._set_interrupted()
|
||||
|
@ -188,14 +190,9 @@ class SSHExploiter(HostExploiter):
|
|||
|
||||
try:
|
||||
self._propagate(ssh)
|
||||
except FailedExploitationError as err:
|
||||
except (FailedExploitationError, RuntimeError) as err:
|
||||
self.exploit_result.error_message = str(err)
|
||||
logger.error(self.exploit_result.error_message)
|
||||
self._publish_propagation_event(False, error_message=self.exploit_result.error_message)
|
||||
except RuntimeError as err:
|
||||
error_message = str(err)
|
||||
self.exploit_result.error_message = error_message
|
||||
logger.error(error_message)
|
||||
finally:
|
||||
ssh.close()
|
||||
return self.exploit_result
|
||||
|
@ -253,7 +250,9 @@ class SSHExploiter(HostExploiter):
|
|||
self.add_executed_cmd(cmdline)
|
||||
|
||||
except Exception as exc:
|
||||
raise FailedExploitationError(f"Error running monkey on victim {self.host}: ({exc})")
|
||||
error_message = f"Error running monkey on victim {self.host}: ({exc})"
|
||||
self._publish_exploitation_event(False, error_message=error_message)
|
||||
raise FailedExploitationError(error_message)
|
||||
|
||||
def _is_port_open(self, ip: IPv4Address, port: int) -> bool:
|
||||
is_open, _ = check_tcp_port(ip, port)
|
||||
|
@ -288,11 +287,7 @@ class SSHExploiter(HostExploiter):
|
|||
logger.error(self.exploit_result.error_message)
|
||||
return False
|
||||
except Exception as exc:
|
||||
self.exploit_result.error_message = (
|
||||
f"Error running uname os command on victim {self.host}: ({exc})"
|
||||
)
|
||||
|
||||
logger.error(self.exploit_result.error_message)
|
||||
logger.error(f"Error running uname os command on victim {self.host}: ({exc})")
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -327,10 +322,9 @@ class SSHExploiter(HostExploiter):
|
|||
|
||||
return ScanStatus.USED
|
||||
except Exception as exc:
|
||||
self.exploit_result.error_message = (
|
||||
f"Error uploading file into victim {self.host}: ({exc})"
|
||||
)
|
||||
logger.error(self.exploit_result.error_message)
|
||||
error_message = f"Error uploading file into victim {self.host}: ({exc})"
|
||||
self._publish_propagation_event(False, error_message=error_message)
|
||||
self.exploit_result.error_message = error_message
|
||||
return ScanStatus.SCANNED
|
||||
|
||||
def _set_executable_bit_on_agent_binary(
|
||||
|
|
Loading…
Reference in New Issue