forked from p34709852/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
|
:rtype: FingerprintData
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# TODO: host should be VictimHost, at the moment it can't because of circular dependency
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def exploit_host(
|
def exploit_host(
|
||||||
self, name: str, host: str, options: Dict, interrupt: threading.Event
|
self, name: str, host: object, options: Dict, interrupt: threading.Event
|
||||||
) -> ExploiterResultData:
|
) -> ExploiterResultData:
|
||||||
"""
|
"""
|
||||||
Runs an exploiter against a remote host
|
Runs an exploiter against a remote host
|
||||||
:param str name: The name of the exploiter to run
|
: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
|
:param Dict options: A dictionary containing options that modify the behavior of the
|
||||||
exploiter
|
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
|
:return: True if exploitation was successful, False otherwise
|
||||||
:rtype: ExploiterResultData
|
:rtype: ExploiterResultData
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -115,7 +115,7 @@ class Exploiter:
|
||||||
credentials = self._get_credentials_for_propagation()
|
credentials = self._get_credentials_for_propagation()
|
||||||
options = {"credentials": credentials, **options}
|
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:
|
def _get_credentials_for_propagation(self) -> Mapping:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -134,8 +134,9 @@ class MockPuppet(IPuppet):
|
||||||
|
|
||||||
return empty_fingerprint_data
|
return empty_fingerprint_data
|
||||||
|
|
||||||
|
# TODO: host should be VictimHost, at the moment it can't because of circular dependency
|
||||||
def exploit_host(
|
def exploit_host(
|
||||||
self, name: str, host: str, options: Dict, interrupt: threading.Event
|
self, name: str, host: object, options: Dict, interrupt: threading.Event
|
||||||
) -> ExploiterResultData:
|
) -> ExploiterResultData:
|
||||||
logger.debug(f"exploit_hosts({name}, {host}, {options})")
|
logger.debug(f"exploit_hosts({name}, {host}, {options})")
|
||||||
attempts = [
|
attempts = [
|
||||||
|
@ -209,7 +210,7 @@ class MockPuppet(IPuppet):
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return successful_exploiters[host][name]
|
return successful_exploiters[host.ip_addr][name]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return ExploiterResultData(
|
return ExploiterResultData(
|
||||||
False, False, os_linux, {}, [], f"{name} failed for host {host}"
|
False, False, os_linux, {}, [], f"{name} failed for host {host}"
|
||||||
|
|
Loading…
Reference in New Issue