From dc1735eb05e1e6f27a0d4b027fc5068055ca48d6 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 4 Oct 2021 17:43:55 +0200 Subject: [PATCH] Agent: Check for empty result in Modify shell files --- CHANGELOG.md | 1 + .../post_breach/actions/modify_shell_startup_files.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12cd863010b..a50e65b3729 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ Changelog](https://keepachangelog.com/en/1.0.0/). - 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 +- Unhandled error when "modify shell startup files PBA" is unable to find regular users. #1507 ### Security diff --git a/monkey/infection_monkey/post_breach/actions/modify_shell_startup_files.py b/monkey/infection_monkey/post_breach/actions/modify_shell_startup_files.py index 18990ab119f..3283bcc94ec 100644 --- a/monkey/infection_monkey/post_breach/actions/modify_shell_startup_files.py +++ b/monkey/infection_monkey/post_breach/actions/modify_shell_startup_files.py @@ -20,6 +20,13 @@ def __init__(self): def run(self): results = [pba.run() for pba in self.modify_shell_startup_PBA_list()] + if not results: + results = [ + ( + "Modify shell startup files PBA failed: Unable to find any regular users", + False, + ) + ] PostBreachTelem(self, results).send() def modify_shell_startup_PBA_list(self): @@ -61,6 +68,7 @@ def run(self): output = subprocess.check_output( # noqa: DUO116 self.command, stderr=subprocess.STDOUT, shell=True ).decode() + return output, True except subprocess.CalledProcessError as e: # Return error output of the command