From 302803b779f2396075348126d5ed87ebaa44dbd8 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 18 Jul 2022 08:26:49 -0400 Subject: [PATCH] Agent: Improve variable names in MimikatzCredentialCollector --- .../mimikatz_credential_collector.py | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/monkey/infection_monkey/credential_collectors/mimikatz_collector/mimikatz_credential_collector.py b/monkey/infection_monkey/credential_collectors/mimikatz_collector/mimikatz_credential_collector.py index bc56efea2..b0299a0c8 100644 --- a/monkey/infection_monkey/credential_collectors/mimikatz_collector/mimikatz_credential_collector.py +++ b/monkey/infection_monkey/credential_collectors/mimikatz_collector/mimikatz_credential_collector.py @@ -14,32 +14,32 @@ logger = logging.getLogger(__name__) class MimikatzCredentialCollector(ICredentialCollector): def collect_credentials(self, options=None) -> Sequence[Credentials]: logger.info("Attempting to collect windows credentials with pypykatz.") - creds = pypykatz_handler.get_windows_creds() - logger.info(f"Pypykatz gathered {len(creds)} credentials.") - return MimikatzCredentialCollector._to_credentials(creds) + windows_credentials = pypykatz_handler.get_windows_creds() + logger.info(f"Pypykatz gathered {len(windows_credentials)} credentials.") + return MimikatzCredentialCollector._to_credentials(windows_credentials) @staticmethod - def _to_credentials(win_creds: Sequence[WindowsCredentials]) -> [Credentials]: - all_creds = [] - for win_cred in win_creds: + def _to_credentials(windows_credentials: Sequence[WindowsCredentials]) -> [Credentials]: + credentials = [] + for wc in windows_credentials: identity = None # Mimikatz picks up users created by the Monkey even if they're successfully deleted # since it picks up creds from the registry. The newly created users are not removed # from the registry until a reboot of the system, hence this check. - if win_cred.username and not win_cred.username.startswith(USERNAME_PREFIX): - identity = Username(win_cred.username) + if wc.username and not wc.username.startswith(USERNAME_PREFIX): + identity = Username(wc.username) - if win_cred.password: - password = Password(win_cred.password) - all_creds.append(Credentials(identity, password)) + if wc.password: + password = Password(wc.password) + credentials.append(Credentials(identity, password)) - if win_cred.lm_hash: - lm_hash = LMHash(lm_hash=win_cred.lm_hash) - all_creds.append(Credentials(identity, lm_hash)) + if wc.lm_hash: + lm_hash = LMHash(lm_hash=wc.lm_hash) + credentials.append(Credentials(identity, lm_hash)) - if win_cred.ntlm_hash: - ntlm_hash = NTHash(nt_hash=win_cred.ntlm_hash) - all_creds.append(Credentials(identity, ntlm_hash)) + if wc.ntlm_hash: + ntlm_hash = NTHash(nt_hash=wc.ntlm_hash) + credentials.append(Credentials(identity, ntlm_hash)) - return all_creds + return credentials