forked from p15670423/monkey
Agent: Update publish methods to accept timestamp
This commit is contained in:
parent
12e9aaf42e
commit
254b4e1c6c
|
@ -3,6 +3,7 @@ import threading
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from ipaddress import IPv4Address
|
from ipaddress import IPv4Address
|
||||||
|
from time import time
|
||||||
from typing import Dict, Sequence, Tuple
|
from typing import Dict, Sequence, Tuple
|
||||||
|
|
||||||
from common.agent_events import ExploitationEvent, PropagationEvent
|
from common.agent_events import ExploitationEvent, PropagationEvent
|
||||||
|
@ -140,32 +141,36 @@ class HostExploiter:
|
||||||
|
|
||||||
def _publish_exploitation_event(
|
def _publish_exploitation_event(
|
||||||
self,
|
self,
|
||||||
exploitation_success: bool,
|
time: float = time(),
|
||||||
|
success: bool = False,
|
||||||
tags: Tuple[str, ...] = tuple(),
|
tags: Tuple[str, ...] = tuple(),
|
||||||
error_message: str = "",
|
error_message: str = "",
|
||||||
):
|
):
|
||||||
exploitation_event = ExploitationEvent(
|
exploitation_event = ExploitationEvent(
|
||||||
source=get_agent_id(),
|
source=get_agent_id(),
|
||||||
target=IPv4Address(self.host.ip_addr),
|
target=IPv4Address(self.host.ip_addr),
|
||||||
success=exploitation_success,
|
success=success,
|
||||||
exploiter_name=self.__class__.__name__,
|
exploiter_name=self.__class__.__name__,
|
||||||
error_message=error_message,
|
error_message=error_message,
|
||||||
|
timestamp=time,
|
||||||
tags=frozenset(tags or self._exploiter_tags),
|
tags=frozenset(tags or self._exploiter_tags),
|
||||||
)
|
)
|
||||||
self.agent_event_queue.publish(exploitation_event)
|
self.agent_event_queue.publish(exploitation_event)
|
||||||
|
|
||||||
def _publish_propagation_event(
|
def _publish_propagation_event(
|
||||||
self,
|
self,
|
||||||
propagation_success: bool,
|
time: float = time(),
|
||||||
|
success: bool = False,
|
||||||
tags: Tuple[str, ...] = tuple(),
|
tags: Tuple[str, ...] = tuple(),
|
||||||
error_message: str = "",
|
error_message: str = "",
|
||||||
):
|
):
|
||||||
propagation_event = PropagationEvent(
|
propagation_event = PropagationEvent(
|
||||||
source=get_agent_id(),
|
source=get_agent_id(),
|
||||||
target=IPv4Address(self.host.ip_addr),
|
target=IPv4Address(self.host.ip_addr),
|
||||||
success=propagation_success,
|
success=success,
|
||||||
exploiter_name=self.__class__.__name__,
|
exploiter_name=self.__class__.__name__,
|
||||||
error_message=error_message,
|
error_message=error_message,
|
||||||
|
timestamp=time,
|
||||||
tags=frozenset(tags or self._propagation_tags),
|
tags=frozenset(tags or self._propagation_tags),
|
||||||
)
|
)
|
||||||
self.agent_event_queue.publish(propagation_event)
|
self.agent_event_queue.publish(propagation_event)
|
||||||
|
|
Loading…
Reference in New Issue