Island: Subscribe to Ping and TCP scan events with ScanEventHandlers

This commit is contained in:
Ilija Lazoroski 2022-09-30 16:17:37 +02:00
parent 2686a7a4ee
commit 8002080c8b
2 changed files with 8 additions and 6 deletions

View File

@ -1,3 +1,4 @@
from .handle_ping_scan_event import handle_ping_scan_event
from .save_event_to_event_repository import save_event_to_event_repository
from .save_stolen_credentials_to_repository import save_stolen_credentials_to_repository
from .scan_event_handler import ScanEventHandler

View File

@ -1,8 +1,8 @@
from common import DIContainer
from common.agent_events import CredentialsStolenEvent, PingScanEvent
from common.agent_events import CredentialsStolenEvent, PingScanEvent, TCPScanEvent
from common.event_queue import IAgentEventQueue
from monkey_island.cc.agent_event_handlers import (
handle_ping_scan_event,
ScanEventHandler,
save_event_to_event_repository,
save_stolen_credentials_to_repository,
)
@ -17,7 +17,7 @@ from monkey_island.cc.repository import (
def setup_agent_event_handlers(container: DIContainer):
_subscribe_and_store_to_event_repository(container)
_subscribe_ping_scan_event(container)
_subscribe_scan_events(container)
def _subscribe_and_store_to_event_repository(container: DIContainer):
@ -32,12 +32,13 @@ def _subscribe_and_store_to_event_repository(container: DIContainer):
agent_event_queue.subscribe_type(CredentialsStolenEvent, save_stolen_credentials_subscriber)
def _subscribe_ping_scan_event(container: DIContainer):
def _subscribe_scan_events(container: DIContainer):
agent_event_queue = container.resolve(IAgentEventQueue)
agent_repository = container.resolve(IAgentRepository)
machine_repository = container.resolve(IMachineRepository)
node_repository = container.resolve(INodeRepository)
handler = handle_ping_scan_event(agent_repository, machine_repository, node_repository)
scan_event_handler = ScanEventHandler(agent_repository, machine_repository, node_repository)
agent_event_queue.subscribe_type(PingScanEvent, handler)
agent_event_queue.subscribe_type(PingScanEvent, scan_event_handler.handle_ping_scan_event)
agent_event_queue.subscribe_type(TCPScanEvent, scan_event_handler.handle_tcp_scan_event)