From bbda9340820d2e641076f8e53bcf3a70c47a1093 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Tue, 5 Oct 2021 16:04:02 +0300 Subject: [PATCH 1/2] Monkey: include credential key into info dict of InfoCollector class This change cleans up the code because the info collectors can just add credentials to the info dictionary without explicitly checking if the key already exists --- monkey/infection_monkey/system_info/__init__.py | 4 +--- monkey/infection_monkey/system_info/windows_info_collector.py | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/monkey/infection_monkey/system_info/__init__.py b/monkey/infection_monkey/system_info/__init__.py index 51da9b869d4..7d065992669 100644 --- a/monkey/infection_monkey/system_info/__init__.py +++ b/monkey/infection_monkey/system_info/__init__.py @@ -59,7 +59,7 @@ class InfoCollector(object): """ def __init__(self): - self.info = {} + self.info = {"credentials": {}} def get_info(self): # Collect all hardcoded @@ -96,8 +96,6 @@ def get_azure_info(self): return logger.debug("Harvesting creds if on an Azure machine") azure_collector = AzureCollector() - if "credentials" not in self.info: - self.info["credentials"] = {} azure_creds = azure_collector.extract_stored_credentials() for cred in azure_creds: username = cred[0] diff --git a/monkey/infection_monkey/system_info/windows_info_collector.py b/monkey/infection_monkey/system_info/windows_info_collector.py index ffc720dff5b..f3242922eb8 100644 --- a/monkey/infection_monkey/system_info/windows_info_collector.py +++ b/monkey/infection_monkey/system_info/windows_info_collector.py @@ -45,8 +45,7 @@ def get_mimikatz_info(self): try: credentials = MimikatzCredentialCollector.get_creds() if credentials: - if "credentials" in self.info: - self.info["credentials"].update(credentials) + self.info["credentials"].update(credentials) logger.info("Mimikatz info gathered successfully") else: logger.info("No mimikatz info was gathered") From bc422128f5e8401ab39abbc2efbce9a5f63a7dc1 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Tue, 5 Oct 2021 17:16:51 +0300 Subject: [PATCH 2/2] Monkey: add CHANGELOG.md entry about fixed Mimikatz credential collector when Azure credential collector is disabled --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d56de4aa8a3..12cd863010b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/). - Some of the gathered credentials no longer appear in database plaintext. #1454 - Encryptor breaking with UTF-8 characters. (Passwords in different languages can be submitted in the config successfully now.) #1490 +- Mimikatz collector no longer fails if Azure credential collector is disabled. #1512 #1493 ### Security