From bf27a8c8ea8f4a7bd87f778b6fac7ce04207c492 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 16 Feb 2022 14:22:44 -0500 Subject: [PATCH] Agent: Do not run pypykatz if the OS is not Windows --- .../mimikatz_collector/pypykatz_handler.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/monkey/infection_monkey/credential_collectors/mimikatz_collector/pypykatz_handler.py b/monkey/infection_monkey/credential_collectors/mimikatz_collector/pypykatz_handler.py index 2b7ceec65..98377bc86 100644 --- a/monkey/infection_monkey/credential_collectors/mimikatz_collector/pypykatz_handler.py +++ b/monkey/infection_monkey/credential_collectors/mimikatz_collector/pypykatz_handler.py @@ -1,10 +1,15 @@ import binascii +import logging from typing import Any, Dict, List, NewType from pypykatz.pypykatz import pypykatz +from infection_monkey.utils.environment import is_windows_os + from .windows_credentials import WindowsCredentials +logger = logging.getLogger(__name__) + CREDENTIAL_TYPES = [ "msv_creds", "wdigest_creds", @@ -19,6 +24,10 @@ PypykatzCredential = NewType("PypykatzCredential", Dict) def get_windows_creds() -> List[WindowsCredentials]: + if not is_windows_os(): + logger.debug("Skipping pypykatz because the operating system is not Windows") + return [] + pypy_handle = pypykatz.go_live() logon_data = pypy_handle.to_dict() windows_creds = _parse_pypykatz_results(logon_data)