示例#1
0
    def use_payload(self, payload):
        while ordnance_helpers.loop_req_options(payload):
            # Soon as we load the payload, show options
            self.print_options_screen(payload)

            while True:
                comp = completer.OrdnanceCompleter(self.shellcode_option_commands, payload)
                readline.set_completer_delims(' \t\n;')
                readline.parse_and_bind("tab: complete")
                readline.set_completer(comp.complete)
                show_payload_menu = False
                shellcode_command = input("[" + payload.cli_name + ">>]: ").strip().lower()

                # Start logic for required option commands
                if shellcode_command.startswith("set"):
                    if len(shellcode_command.split()) < 3 or len(shellcode_command.split()) > 3:
                        print()
                        print(helpers.color(" [!] ERROR: You did not provide the correct input for setting an option!", warning=True))
                        print(helpers.color(" [*] Ex: set LHOST 192.168.18.14", warning=True))
                        print()
                    else:
                        found_req_option = False
                        for key, value in payload.required_options.items():
                            if shellcode_command.split()[1] == key.lower():
                                found_req_option = True
                                value[0] = shellcode_command.split()[2]
                        if not found_req_option:
                            print()
                            print(helpers.color(" [!] ERROR: You didn't provide a correct option to set, please retry!", warning=True))
                            print()
                elif shellcode_command.startswith("exit") or shellcode_command.startswith("quit"):
                    sys.exit(0)
                elif shellcode_command.startswith("back") or shellcode_command.startswith("main") or shellcode_command.startswith("menu"):
                    show_payload_menu = True
                    break
                elif shellcode_command.startswith("list"):
                    ordnance_helpers.title_screen()
                    self.print_encoders()
                elif shellcode_command.startswith("gen") or shellcode_command.startswith("run"):
                    lport_out = ""
                    lhost_out = ""
                    rhost_out = ""
                    if ordnance_helpers.loop_req_options(payload):
                        print()
                        print(helpers.color(" [!] ERROR: You didn't provide all the required options!", warning=True))
                        print()
                    else:
                        safe_to_generate = True
                        if "LHOST" in payload.required_options:
                            if not ordnance_helpers.check_lhost(payload.required_options["LHOST"][0]):
                                print()
                                print(helpers.color(" [!] ERROR: You didn't provide a valid IP address!", warning=True))
                                print(helpers.color(" [!] ERROR: Try again :)", warning=True))
                                print()
                                safe_to_generate = False
                        if "LPORT" in payload.required_options:
                            if not ordnance_helpers.check_lport(payload.required_options["LPORT"][0]):
                                print()
                                print(helpers.color(" [!] ERROR: You didn't provide a valid LPORT value!", warning=True))
                                print(helpers.color(" [!] ERROR: Try again :)", warning=True))
                                print()
                                safe_to_generate = False
                        if safe_to_generate:
                            # Generate the shellcode
                            payload.gen_shellcode()

                            # Gather information to generate handler if requested
                            self.final_shellcode = payload.customized_shellcode
                            if "LHOST" in payload.required_options:
                                lhost_out = payload.required_options["LHOST"][0]
                            if "LPORT" in payload.required_options:
                                lport_out = payload.required_options["LPORT"][0]
                            if "RHOST" in payload.required_options:
                                rhost_out = payload.required_options["RHOST"][0]

                            if lhost_out:
                                self.payload_options['LHOST'] = lhost_out
                            if lport_out:
                                self.payload_options['LPORT'] = lport_out
                            if rhost_out:
                                self.payload_options['RHOST'] = rhost_out

                            # Check if encoder is needed
                            if payload.required_options["Encoder"][0] is not "None":
                                self.use_encoder(payload)
                                self.final_shellcode = payload.customized_shellcode

                            # Print banner & payload stats
                            ordnance_helpers.title_screen()
                            payload.payload_stats()

                            # Did we come from Evasion? Or direct from Ordnance...
                            if self.invoked:
                                print('\nHalf way... ' + helpers.color('Shellcode generated with Veil-Ordnance!') + '   Returning to Veil-Evasion.')

                                # Re-set settings
                                if "LHOST" in payload.required_options:
                                    payload.required_options["LHOST"][0] = ""
                                if "LPORT" in payload.required_options:
                                    payload.required_options["LPORT"][0] = ""
                            else:
                                dummy = input("\n" + helpers.color('Done!') + "Hit enter to continue...")

                            show_payload_menu = True
                            break
                elif shellcode_command.startswith("option"):
                    # Reprint the shellcode options to console
                    self.print_options_screen(payload)

            if show_payload_menu:
                if not self.invoked:
                    self.print_menu()
                break
        return
示例#2
0
文件: tool.py 项目: yuhisern7/Veil
    def use_payload(self, incoming_payload):
        shellcode_found = False
        for payload in self.active_shellcode.values():
            if incoming_payload.lower() == payload.cli_name:
                shellcode_found = True
                while ordnance_helpers.loop_req_options(payload):
                    self.print_options_screen(payload)

                    while True:
                        comp = completer.OrdnanceCompleter(
                            self.shellcode_option_commands, payload)
                        readline.set_completer_delims(' \t\n;')
                        readline.parse_and_bind("tab: complete")
                        readline.set_completer(comp.complete)
                        breakout = False
                        shellcode_command = input("[" + payload.cli_name +
                                                  ">>]: ").lower().strip()

                        # Start logic for required option commands
                        if shellcode_command.startswith("set"):
                            if len(shellcode_command.split()) < 3 or len(
                                    shellcode_command.split()) > 3:
                                print(
                                    helpers.color(
                                        "[*] Error: You did not provide the correct input for setting an option!",
                                        warning=True))
                                print(
                                    helpers.color(
                                        "[*] Error: Ex: set LHOST 192.168.18.14"
                                    ))
                            else:
                                found_req_option = False
                                for key, value in payload.required_options.items(
                                ):
                                    if shellcode_command.split(
                                    )[1] == key.lower():
                                        found_req_option = True
                                        value[0] = shellcode_command.split()[2]
                                if not found_req_option:
                                    print(
                                        helpers.color(
                                            "[*] Error: You didn't provide a correct option to set, please retry!",
                                            warning=True))
                        elif shellcode_command == "exit":
                            # Completely exit out of Veil
                            print(
                                helpers.color(
                                    "[*] You're rage quitting all of Veil!",
                                    warning=True))
                            sys.exit(0)
                        elif shellcode_command == "back":
                            # Go back to shellcode selection
                            shellcode_command = ''
                            breakout = True
                            break
                        elif shellcode_command == "generate":
                            lport_out = ''
                            lhost_out = ''
                            rhost_out = ''
                            if ordnance_helpers.loop_req_options(payload):
                                print(
                                    helpers.color(
                                        "[*] Error: You didn't provide all the required options!",
                                        warning=True))
                            else:
                                safe_to_generate = True
                                if "LHOST" in payload.required_options:
                                    if not ordnance_helpers.check_lhost(
                                            payload.required_options["LHOST"]
                                        [0]):
                                        print(
                                            helpers.color(
                                                "[*] Error: You didn't provide a valid IP address!",
                                                warning=True))
                                        print(
                                            helpers.color(
                                                "[*] Error: Try again :)",
                                                warning=True))
                                        safe_to_generate = False
                                if "LPORT" in payload.required_options:
                                    if not ordnance_helpers.check_lport(
                                            payload.required_options["LPORT"]
                                        [0]):
                                        print(
                                            helpers.color(
                                                "[*] Error: You didn't provide a valid LPORT value!",
                                                warning=True))
                                        print(
                                            helpers.color(
                                                "[*] Error: Try again :)",
                                                warning=True))
                                        safe_to_generate = False
                                if safe_to_generate:
                                    # Generate the shellcode
                                    payload.gen_shellcode()
                                    # Gather information to generate handler if requested
                                    self.final_shellcode = payload.customized_shellcode
                                    if "LHOST" in payload.required_options:
                                        lhost_out = payload.required_options[
                                            "LHOST"][0]
                                    if "LPORT" in payload.required_options:
                                        lport_out = payload.required_options[
                                            "LPORT"][0]
                                    if "RHOST" in payload.required_options:
                                        rhost_out = payload.required_options[
                                            "RHOST"][0]

                                    if lhost_out:
                                        self.payload_options[
                                            'LHOST'] = lhost_out
                                    if lport_out:
                                        self.payload_options[
                                            'LPORT'] = lport_out
                                    if rhost_out:
                                        self.payload_options[
                                            'RHOST'] = rhost_out

                                    # Check if encoder is needed
                                    if payload.required_options["Encoder"][
                                            0] is not "None":
                                        self.use_encoder(payload)
                                        self.final_shellcode = payload.customized_shellcode

                                    # Print payload stats
                                    payload.payload_stats()
                                    if self.invoked:
                                        dummy = input(
                                            '\nHit enter to return to Veil-Evasion... '
                                        )
                                    else:
                                        dummy2 = input(
                                            '\nHit enter to continue... ')
                                    shellcode_command = ''

                                    if "LHOST" in payload.required_options:
                                        payload.required_options["LHOST"][
                                            0] = ''
                                    if "LPORT" in payload.required_options:
                                        payload.required_options["LPORT"][
                                            0] = ''
                                    breakout = True
                                    break
                        elif shellcode_command == "options":
                            # Reprint the shellcode options to console
                            self.print_options_screen(payload)

                    if breakout:
                        ordnance_helpers.title_screen()
                        print("Veil-Ordnance Menu")
                        print("\n\t" +
                              helpers.color(len(self.active_shellcode)) +
                              " payloads loaded")
                        print("\t" + helpers.color(len(self.active_encoders)) +
                              " encoders loaded\n")
                        print("Available Commands:\n")
                        for command in sorted(
                                self.ordnance_main_menu_commands.keys()):
                            print("\t" + helpers.color(command) + '\t\t\t' +
                                  self.ordnance_main_menu_commands[command])
                        print()
                        break

        if not shellcode_found:
            print(
                helpers.color(
                    "[*] Error: You did not provide a valid payload name, please try again!",
                    warning=True))
        return