示例#1
0
文件: option.py 项目: meraznara/rpo
    def __set__(self, instance, value):
        try:
            value = int(value)

            if 0 < value <= 65535:  # max port number is 65535
                self.display_value = str(value)
                self.value = value
            else:
                raise OptionValidationError("Invalid option. Port value should be between 0 and 65536.")
        except ValueError:
            raise OptionValidationError("Invalid option. Cannot cast '{}' to integer.".format(value))
示例#2
0
    def _apply_widget(self, value):
        try:
            value = int(value)

            if 0 < value <= 65535:  # max port number is 65535
                return value
            else:
                raise OptionValidationError(
                    "Invalid option. Port value should be between 0 and 65536."
                )
        except ValueError:
            raise OptionValidationError(
                "Invalid option. Cannot cast '{}' to integer.".format(value))
示例#3
0
 def _apply_widget(self, value):
     if is_ipv4(value) or is_ipv6(value):
         return value
     else:
         raise OptionValidationError(
             "Invalid address. Provided address is not valid IPv4 or IPv6 address."
         )
示例#4
0
    def run(self):
        print_status("Generating payload")
        try:
            data = self.generate()
        except OptionValidationError as e:
            print_error(e)
            return

        if self.output == "elf":
            with open(self.filepath, 'wb+') as f:
                print_status("Building ELF payload")
                content = self.generate_elf(data)
                print_success("Saving file {}".format(self.filepath))
                f.write(content)
        elif self.output == "c":
            print_success("Bulding payload for C")
            content = self.generate_c(data)
            print_info(content)
        elif self.output == "python":
            print_success("Building payload for python")
            content = self.generate_python(data)
            print_info(content)
        else:
            raise OptionValidationError(
                "No such option as {}".format(self.output)
            )
示例#5
0
 def __set__(self, instance, value):
     try:
         self.display_value = str(value)
         self.value = float(value)
     except ValueError:
         raise OptionValidationError(
             "Invalid option. Cannot cast '{}' to float.".format(value))
示例#6
0
 def __init__(self):
     if self.handler not in PayloadHandlers:
         raise OptionValidationError(
             "Please use one of valid payload handlers: {}".format(
                 PayloadHandlers._fields
             )
         )
示例#7
0
 def __set__(self, instance, value):
     if not value or is_ipv4(value) or is_ipv6(value) or value == "localip":
         self.value = self.display_value = value
     else:
         raise OptionValidationError(
             "Invalid address. Provided address is not valid IPv4 or IPv6 address."
         )
示例#8
0
文件: option.py 项目: meraznara/rpo
    def __set__(self, instance, value):
        if value.startswith("file://"):
            path = value.replace("file://", "")
            if not os.path.exists(path):
                raise OptionValidationError("File '{}' does not exist.".format(path))

        self.value = self.display_value = value
示例#9
0
 def __set__(self, instance, value):
     regexp = r"^[a-f\d]{1,2}:[a-f\d]{1,2}:[a-f\d]{1,2}:[a-f\d]{1,2}:[a-f\d]{1,2}:[a-f\d]{1,2}$"
     if re.match(regexp, value.lower()):
         self.value = self.display_value = value
     else:
         raise OptionValidationError(
             "Invalid option. '{}' is not a valid MAC address".format(
                 value))
示例#10
0
文件: option.py 项目: meraznara/rpo
    def __set__(self, instance, value):
        encoder = instance.get_encoder(value)

        if encoder:
            self.value = encoder
            self.display_value = value
        else:
            raise OptionValidationError("Encoder not available. Check available encoders with `show encoders`.")
示例#11
0
 def _apply_widget(self, value):
     regexp = r"^[a-f\d]{1,2}:[a-f\d]{1,2}:[a-f\d]{1,2}:[a-f\d]{1,2}:[a-f\d]{1,2}:[a-f\d]{1,2}$"
     if re.match(regexp, value.lower()):
         return value
     else:
         raise OptionValidationError(
             "Invalid option. '{}' is not a valid MAC address".format(
                 value))
示例#12
0
    def __init__(self):
        super(ArchitectureSpecificPayload, self).__init__()
        if self.architecture not in Architectures:
            raise OptionValidationError(
                "Please use one of valid payload architectures: {}".format(
                    Architectures._fields))

        self.header = ARCH_ELF_HEADERS[self.architecture]
        self.bigendian = True if self.architecture.endswith("be") else False
示例#13
0
文件: option.py 项目: meraznara/rpo
 def __set__(self, instance, value):
     if value == "true":
         self.value = True
         self.display_value = value
     elif value == "false":
         self.value = False
         self.display_value = value
     else:
         raise OptionValidationError("Invalid value. It should be true or false.")
示例#14
0
    def _apply_widget(self, value):
        if value.startswith("file://"):
            path = value.replace("file://", "")
            if not os.path.exists(path):
                raise OptionValidationError(
                    "File '{}' does not exist.".format(path))
            return value

        return value
    def __set__(self, instance, value):
        if not value:
            self.value = self.display_value = ''
            return

        name, _, _ = value.strip().partition(':')
        engine = get_engine_module(name)
        if engine.parse_protocal(value):
            self.value = self.display_value = value
        else:
            raise OptionValidationError("Invalid engine.")
示例#16
0
文件: option.py 项目: meraznara/rpo
    def __init__(self, default, description="", advanced=False):
        self.description = description

        if default:
            self.display_value = "true"
        else:
            self.display_value = "false"

        self.value = default

        try:
            self.advanced = bool(advanced)
        except ValueError:
            raise OptionValidationError("Invalid value. Cannot cast '{}' to boolean.".format(advanced))
示例#17
0
文件: option.py 项目: meraznara/rpo
    def __init__(self, default, description="", advanced=False):
        self.label = None
        self.description = description

        try:
            self.advanced = bool(advanced)
        except ValueError:
            raise OptionValidationError("Invalid value. Cannot cast '{}' to boolean.".format(advanced))

        if default or default == 0:
            self.__set__("", default)
        else:
            self.display_value = ""
            self.value = ""
示例#18
0
 def _apply_widget(self, value):
     try:
         return float(value)
     except ValueError:
         raise OptionValidationError(
             "Invalid option. Cannot cast '{}' to float.".format(value))
示例#19
0
 def _apply_widget(self, value):
     if value in ["true", "false"]:
         return value
     else:
         raise OptionValidationError(
             "Invalid value. It should be true or false.")