Merge pull request #2317 from guardicore/fix-zerologon

Fix zerologon
This commit is contained in:
Mike Salvatore 2022-09-19 10:16:19 -04:00 committed by GitHub
commit 9f697e57d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -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)

View File

@ -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}")