forked from p15670423/monkey
Agent: Modify exploit_host() to accept object instead of string
This commit is contained in:
parent
f2b2a9c5c3
commit
58b1a04bd7
|
@ -102,16 +102,19 @@ class IPuppet(metaclass=abc.ABCMeta):
|
|||
:rtype: FingerprintData
|
||||
"""
|
||||
|
||||
# TODO: host should be VictimHost, at the moment it can't because of circular dependency
|
||||
@abc.abstractmethod
|
||||
def exploit_host(
|
||||
self, name: str, host: str, options: Dict, interrupt: threading.Event
|
||||
self, name: str, host: object, options: Dict, interrupt: threading.Event
|
||||
) -> ExploiterResultData:
|
||||
"""
|
||||
Runs an exploiter against a remote host
|
||||
:param str name: The name of the exploiter to run
|
||||
:param str host: The domain name or IP address of a host
|
||||
:param object host: The domain name or IP address of a host
|
||||
:param Dict options: A dictionary containing options that modify the behavior of the
|
||||
exploiter
|
||||
:param threading.Event interrupt: A threading.Event object that signals the exploit to stop
|
||||
executing and clean itself up.
|
||||
:return: True if exploitation was successful, False otherwise
|
||||
:rtype: ExploiterResultData
|
||||
"""
|
||||
|
|
|
@ -115,7 +115,7 @@ class Exploiter:
|
|||
credentials = self._get_credentials_for_propagation()
|
||||
options = {"credentials": credentials, **options}
|
||||
|
||||
return self._puppet.exploit_host(exploiter_name, victim_host.ip_addr, options, stop)
|
||||
return self._puppet.exploit_host(exploiter_name, victim_host, options, stop)
|
||||
|
||||
def _get_credentials_for_propagation(self) -> Mapping:
|
||||
try:
|
||||
|
|
|
@ -134,8 +134,9 @@ class MockPuppet(IPuppet):
|
|||
|
||||
return empty_fingerprint_data
|
||||
|
||||
# TODO: host should be VictimHost, at the moment it can't because of circular dependency
|
||||
def exploit_host(
|
||||
self, name: str, host: str, options: Dict, interrupt: threading.Event
|
||||
self, name: str, host: object, options: Dict, interrupt: threading.Event
|
||||
) -> ExploiterResultData:
|
||||
logger.debug(f"exploit_hosts({name}, {host}, {options})")
|
||||
attempts = [
|
||||
|
@ -209,7 +210,7 @@ class MockPuppet(IPuppet):
|
|||
}
|
||||
|
||||
try:
|
||||
return successful_exploiters[host][name]
|
||||
return successful_exploiters[host.ip_addr][name]
|
||||
except KeyError:
|
||||
return ExploiterResultData(
|
||||
False, False, os_linux, {}, [], f"{name} failed for host {host}"
|
||||
|
|
Loading…
Reference in New Issue