diff --git a/infection_monkey/windows_upgrader.py b/infection_monkey/windows_upgrader.py index cbd879c15..4ee0462c5 100644 --- a/infection_monkey/windows_upgrader.py +++ b/infection_monkey/windows_upgrader.py @@ -32,10 +32,14 @@ class WindowsUpgrader(object): @staticmethod def upgrade(opts): - monkey_64_path = ControlClient.download_monkey_exe_by_os(True, False) - with monkeyfs.open(monkey_64_path, "rb") as downloaded_monkey_file: - with open(WormConfiguration.dropper_target_path_win_64, 'wb') as written_monkey_file: - shutil.copyfileobj(downloaded_monkey_file, written_monkey_file) + try: + monkey_64_path = ControlClient.download_monkey_exe_by_os(True, False) + with monkeyfs.open(monkey_64_path, "rb") as downloaded_monkey_file: + with open(WormConfiguration.dropper_target_path_win_64, 'wb') as written_monkey_file: + shutil.copyfileobj(downloaded_monkey_file, written_monkey_file) + except (IOError, AttributeError): + LOG.error("Failed to download the Monkey to the target path.") + return monkey_options = build_monkey_commandline_explicitly(opts.parent, opts.tunnel, opts.server, opts.depth)