From 0c6997c147346856765854c02e265906dcafc396 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 19 Sep 2022 15:52:04 +0200 Subject: [PATCH 1/2] BB: Get the secret value from credentials in ZerologonAnalyzer --- envs/monkey_zoo/blackbox/analyzers/zerologon_analyzer.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/envs/monkey_zoo/blackbox/analyzers/zerologon_analyzer.py b/envs/monkey_zoo/blackbox/analyzers/zerologon_analyzer.py index 40905a28c..b19be0273 100644 --- a/envs/monkey_zoo/blackbox/analyzers/zerologon_analyzer.py +++ b/envs/monkey_zoo/blackbox/analyzers/zerologon_analyzer.py @@ -28,20 +28,21 @@ class ZerologonAnalyzer(Analyzer): def _analyze_credential_gathering(self) -> bool: propagation_credentials = self.island_client.get_propagation_credentials() + self.log.add_entry(f"Credentials from endpoint: {propagation_credentials}") credentials_on_island = ZerologonAnalyzer._get_relevant_credentials(propagation_credentials) + self.log.add_entry(f"Relevant credentials: {credentials_on_island}") return self._is_all_credentials_in_list(credentials_on_island) @staticmethod def _get_relevant_credentials(propagation_credentials: Credentials) -> List[str]: credentials_on_island = set() - for credentials in propagation_credentials: if isinstance(credentials.identity, Username): credentials_on_island.update([credentials.identity.username]) if isinstance(credentials.secret, NTHash): - credentials_on_island.update([credentials.secret.nt_hash]) + credentials_on_island.update([credentials.secret.nt_hash.get_secret_value()]) if isinstance(credentials.secret, LMHash): - credentials_on_island.update([credentials.secret.lm_hash]) + credentials_on_island.update([credentials.secret.lm_hash.get_secret_value()]) return list(credentials_on_island) From 2857e70fa2d9f204ac696883844eac423102a5ea Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 19 Sep 2022 15:52:44 +0200 Subject: [PATCH 2/2] Island: Change credentials stolen event subscriber argument name --- .../save_stolen_credentials_to_repository.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/monkey/monkey_island/cc/agent_event_handlers/save_stolen_credentials_to_repository.py b/monkey/monkey_island/cc/agent_event_handlers/save_stolen_credentials_to_repository.py index dd23cef94..20e4a365b 100644 --- a/monkey/monkey_island/cc/agent_event_handlers/save_stolen_credentials_to_repository.py +++ b/monkey/monkey_island/cc/agent_event_handlers/save_stolen_credentials_to_repository.py @@ -14,10 +14,8 @@ class save_stolen_credentials_to_repository: def __init__(self, credentials_repository: ICredentialsRepository): self._credentials_repository = credentials_repository - def __call__(self, credentials_stolen_event: CredentialsStolenEvent): + def __call__(self, event: CredentialsStolenEvent): try: - self._credentials_repository.save_stolen_credentials( - credentials_stolen_event.stolen_credentials - ) + self._credentials_repository.save_stolen_credentials(event.stolen_credentials) except StorageError as err: logger.error(f"Error occurred while storing stolen credentials: {err}")