diff --git a/monkey/infection_monkey/post_breach/signed_script_proxy/signed_script_proxy.py b/monkey/infection_monkey/post_breach/signed_script_proxy/signed_script_proxy.py index 56bae8b25..b172d1ab1 100644 --- a/monkey/infection_monkey/post_breach/signed_script_proxy/signed_script_proxy.py +++ b/monkey/infection_monkey/post_breach/signed_script_proxy/signed_script_proxy.py @@ -1,3 +1,4 @@ +import logging import subprocess from common.common_consts.timeouts import SHORT_REQUEST_TIMEOUT @@ -8,6 +9,8 @@ from infection_monkey.post_breach.signed_script_proxy.windows.signed_script_prox ) from infection_monkey.utils.environment import is_windows_os +logger = logging.getLogger(__name__) + def get_commands_to_proxy_execution_using_signed_script(): windows_cmds = get_windows_commands_to_proxy_execution_using_signed_script() @@ -16,11 +19,18 @@ def get_commands_to_proxy_execution_using_signed_script(): def cleanup_changes(original_comspec): if is_windows_os(): - subprocess.run( # noqa: DUO116 - get_windows_commands_to_reset_comspec(original_comspec), - shell=True, - timeout=SHORT_REQUEST_TIMEOUT, - ) - subprocess.run( # noqa: DUO116 - get_windows_commands_to_delete_temp_comspec(), shell=True, timeout=SHORT_REQUEST_TIMEOUT - ) + try: + subprocess.run( # noqa: DUO116 + get_windows_commands_to_reset_comspec(original_comspec), + shell=True, + timeout=SHORT_REQUEST_TIMEOUT, + ) + subprocess.run( # noqa: DUO116 + get_windows_commands_to_delete_temp_comspec(), + shell=True, + timeout=SHORT_REQUEST_TIMEOUT, + ) + except subprocess.CalledProcessError as err: + logger.error(err.output.decode()) + except subprocess.TimeoutExpired as err: + logger.error(str(err))