Esempio n. 1
0
    def upgrade(opts):
        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)

        monkey_cmdline = MONKEY_CMDLINE_WINDOWS % {
            'monkey_path': WormConfiguration.dropper_target_path_win_64
        } + monkey_options

        monkey_process = subprocess.Popen(monkey_cmdline,
                                          shell=True,
                                          stdin=None,
                                          stdout=None,
                                          stderr=None,
                                          close_fds=True,
                                          creationflags=DETACHED_PROCESS)

        LOG.info(
            "Executed 64bit monkey process (PID=%d) with command line: %s",
            monkey_process.pid, monkey_cmdline)

        time.sleep(WindowsUpgrader.__UPGRADE_WAIT_TIME__)
        if monkey_process.poll() is not None:
            LOG.error("Seems like monkey died too soon")
Esempio n. 2
0
def get_target_monkey_by_os(is_windows, is_32bit):
    from control import ControlClient
    return ControlClient.download_monkey_exe_by_os(is_windows, is_32bit)
Esempio n. 3
0
def get_target_monkey_by_os(is_windows, is_32bit):
    from control import ControlClient
    return ControlClient.download_monkey_exe_by_os(is_windows, is_32bit)