Agent: Update publish methods to accept timestamp

This commit is contained in:
Kekoa Kaaikala 2022-10-05 19:43:25 +00:00
parent 12e9aaf42e
commit 254b4e1c6c
1 changed files with 9 additions and 4 deletions

View File

@ -3,6 +3,7 @@ import threading
from abc import abstractmethod
from datetime import datetime
from ipaddress import IPv4Address
from time import time
from typing import Dict, Sequence, Tuple
from common.agent_events import ExploitationEvent, PropagationEvent
@ -140,32 +141,36 @@ class HostExploiter:
def _publish_exploitation_event(
self,
exploitation_success: bool,
time: float = time(),
success: bool = False,
tags: Tuple[str, ...] = tuple(),
error_message: str = "",
):
exploitation_event = ExploitationEvent(
source=get_agent_id(),
target=IPv4Address(self.host.ip_addr),
success=exploitation_success,
success=success,
exploiter_name=self.__class__.__name__,
error_message=error_message,
timestamp=time,
tags=frozenset(tags or self._exploiter_tags),
)
self.agent_event_queue.publish(exploitation_event)
def _publish_propagation_event(
self,
propagation_success: bool,
time: float = time(),
success: bool = False,
tags: Tuple[str, ...] = tuple(),
error_message: str = "",
):
propagation_event = PropagationEvent(
source=get_agent_id(),
target=IPv4Address(self.host.ip_addr),
success=propagation_success,
success=success,
exploiter_name=self.__class__.__name__,
error_message=error_message,
timestamp=time,
tags=frozenset(tags or self._propagation_tags),
)
self.agent_event_queue.publish(propagation_event)