From 3fe6d2456b51d01a2dbfb33992743fcd5ad43bfb Mon Sep 17 00:00:00 2001 From: Daniel Goldberg Date: Tue, 17 Apr 2018 11:27:35 +0300 Subject: [PATCH] Bugfix when upgrading the monkey without admin permissions. Can happen during development or future exploit flows --- infection_monkey/windows_upgrader.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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)