From a6c2762823c5118a27f016f3ca3263fa914278c7 Mon Sep 17 00:00:00 2001 From: vakarisz Date: Tue, 15 Feb 2022 10:36:33 +0200 Subject: [PATCH] Agent: change mimikatz collector to return a list of credentials --- .../mimikatz_collector/mimikatz_cred_collector.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/monkey/infection_monkey/credential_collectors/mimikatz_collector/mimikatz_cred_collector.py b/monkey/infection_monkey/credential_collectors/mimikatz_collector/mimikatz_cred_collector.py index 46fb77d6e..534580145 100644 --- a/monkey/infection_monkey/credential_collectors/mimikatz_collector/mimikatz_cred_collector.py +++ b/monkey/infection_monkey/credential_collectors/mimikatz_collector/mimikatz_cred_collector.py @@ -13,15 +13,15 @@ from .windows_credentials import WindowsCredentials class MimikatzCredentialCollector(ICredentialCollector): - def collect_credentials(self) -> Credentials: + def collect_credentials(self) -> List[Credentials]: creds = pypykatz_handler.get_windows_creds() return MimikatzCredentialCollector.to_credentials(creds) @staticmethod - def to_credentials(win_creds: List[WindowsCredentials]) -> Credentials: - creds_obj = Credentials(identities=[], secrets=[]) + def to_credentials(win_creds: List[WindowsCredentials]) -> [Credentials]: + all_creds = [] for win_cred in win_creds: - + creds_obj = Credentials(identities=[], secrets=[]) if win_cred.username: identity = Username(win_cred.username) creds_obj.identities.append(identity) @@ -34,4 +34,7 @@ class MimikatzCredentialCollector(ICredentialCollector): hashes = NTHashes(ntlm_hash=win_cred.ntlm_hash, lm_hash=win_cred.lm_hash) creds_obj.secrets.append(hashes) - return creds_obj + if creds_obj.identities != [] or creds_obj.secrets != []: + all_creds.append(creds_obj) + + return all_creds