Пример #1
0
 def __init__(self, pb2_api, name='ProtobufRunner', logger=None):
     super(ProtobufRunner, self).__init__(name, logger)
     self.pb2_api = pb2_api
     self.config = ConfigParser()
     self.target_host = self.config.get_target_host_name()
     self.target_port = self.config.get_target_port()
     self.frmu = FrameworkUtils()
Пример #2
0
    def __init__(self,
                 name=str,
                 host=str,
                 port=int,
                 max_retries=10,
                 timeout=None,
                 logger=None,
                 pb2_module=None) -> None:
        """
        Class creates the protobuf payload with the marriage of Fuzzed data.

        :param name: name of the class
        :param host: target host
        :param port: target port
        :param max_retries: maximum retries of connection
        :param timeout: timeout
        :param logger: kitty logger
        """
        super(ProtobufTarget, self).__init__(name, logger)
        self.host = host
        self.port = port
        if (host is None) or (port is None):
            raise ValueError('Host and port may not be None')
        self.timeout = timeout
        self.socket = None
        self.max_retries = max_retries
        self.pb2_module = pb2_module
        self.set_expect_response(False)
        self.config = ConfigParser()
        self.verbosity = self.config.get_generic_verbosity()
        self.logger.setLevel(self.verbosity)
        self.module_path = self.config.get_module_path()
        self._uuid = GenerateUUID.generate_uuid()
        self.frmwrk_utils = FrameworkUtils()
Пример #3
0
 def __init__(self,
              name,
              host,
              port,
              max_retries=10,
              timeout=None,
              logger=None) -> object:
     """
     :param name: name of the target
     :param host: host ip (to send data to) currently unused
     :param port: port to send to
     :param max_retries: maximum connection retries (default: 10)
     :param timeout: socket timeout (default: None)
     :param logger: logger for the object (default: None)
     """
     super(HttpTarget, self).__init__(name, logger)
     self.host = host
     self.port = port
     if (host is None) or (port is None):
         raise ValueError('host and port may not be None')
     self.timeout = timeout
     self.socket = None
     self.max_retries = max_retries
     self.config = ConfigParser()
     self.use_tls = self.config.get_tls()
     self.target_host = self.config.get_target_host_name()
     self.report = Report('report')
     self._uuid = GenerateUUID.generate_uuid()
Пример #4
0
 def __init__(self, name, host, port, timeout=None, logger=None):
     """
     :param name: name of the target
     :param host: host ip (to send data to) currently unused
     :param port: port to send to
     :param timeout: socket timeout (default: None)
     :param logger: logger for the object (default: None)
     """
     super(DnsTarget, self).__init__(name, logger)
     self.host = host
     self.port = port
     if (host is None) or (port is None):
         raise ValueError('Host and port may not be None!')
     self.timeout = timeout
     self.socket = None
     self.bind_host = None
     self.bind_port = None
     self.expect_response = False
     self.config = ConfigParser()
     self.dns_a_record_status = self.config.get_dns_a_record_status()
     self.dns_ns_record_status = self.config.get_dns_ns_record_status()
     self.dns_txt_record_status = self.config.get_dns_txt_record_status()
     self.verbosity = self.config.get_generic_verbosity()
     self.logger.setLevel(self.verbosity)
     self._uuid = GenerateUUID.generate_uuid()
     self.question_length = None
Пример #5
0
 def _get_case_description(self):
     get_desc = ConfigParser()
     if get_desc.get_protocol_dns() is True:
         return get_desc.get_dns_case_desc()
     elif get_desc.get_protocol_http() is True:
         return get_desc.get_http_case_desc()
     elif get_desc.get_protocol_protobuf is True:
         return get_desc.get_protobuf_case_desc()
Пример #6
0
 def __init__(self, name='DnsRunner', logger=None):
     super(DnsRunner, self).__init__(name, logger)
     self.config = ConfigParser()
     self.target_host = self.config.get_target_host_name()
     self.target_port = self.config.get_target_port()
     self.timeout = self.config.get_dns_timout()
     self.tld = self.config.get_dns_tld()
     self.default_labels = self.config.get_dns_default_labels()
Пример #7
0
 def __init__(self, name='Runner', logger=None):
     super(Runner, self).__init__(name, logger)
     self.config = ConfigParser()
     self.framework_utils = FrameworkUtils()
     self.put_archive_to_s3 = PutArchiveToS3()
     self.proto_path = self.config.get_generic_proto_path()
     self.pb2_path = self.config.get_generic_pb2_path()
     self.verbosity = self.config.get_generic_verbosity()
     self.module_path = self.config.get_module_path()
     self.proto_modules = self.config.get_protobuf_modules()
     self.proto_classes = self.config.get_protobuf_classes_to_send()
     self.protocol_proto = self.config.get_protocol_protobuf()
     self.protocol_http = self.config.get_protocol_http()
     self.protocol_dns = self.config.get_protocol_dns()
     self.set_verbosity(self.verbosity)
     self.use_s3_to_archive = self.config.get_archive_to_s3()
Пример #8
0
    def _get_message_by_config(self, pb_obj: object) -> list:
        """
        A compare and section creation depending on the provided class list in ['protobuf']['classes'] config
        object; If it is empty we rely on the protobuf descriptor information and we process every top
        level messages, if list is provided then the logic seeking for section amid messages and config provided
        messages, obviously logic process only the section of the two aggregation. For comparing the two lists
        the logic uses the string representation of messages via _message_types_by_names.
        The method will returns the list of message_types_by_items method which is a list of tuples including
        the string representation of the message and the object as well.

        :param pb_obj: protobuf object
        :return: list of top level messages
        :rtype: list
        """
        configuration = ConfigParser()
        messages_by_config: list = configuration.get_protobuf_classes_to_send()
        messages_by_name: list = self._message_types_by_name_keys(pb_obj)
        messages_by_item: list = self._message_types_by_name_items(pb_obj)

        if not messages_by_config:
            return list(messages_by_item)

        intersection = list(set(messages_by_name) & set(messages_by_config))
        if len(messages_by_config) == len(intersection) and \
           len(list(messages_by_name)) == len(intersection):
            self.logger.info(
                f"PPROT MSG - Messages provided by configuration: {messages_by_config} "
                f"messages by pb object: {list(messages_by_name)} - section: {intersection} - OK!"
            )
            return list(messages_by_item)
        if len(intersection) < len(list(messages_by_name)):
            for inter_item in intersection:
                for msg_str_item, _ in list(messages_by_item):
                    if inter_item not in msg_str_item:  # remove tuple from list
                        return list(
                            filter(
                                lambda x: str(x[0]) not in str(msg_str_item),
                                list(messages_by_item)))
        else:
            self.logger.info(
                f"PPROT MSG - Config message {len(messages_by_name)} and section "
                f"{intersection} mismatch!"
                f"Maybe something wrong in the config ['protobuf']['classes'] field!"
            )
            raise MessageCompareException

        return []
Пример #9
0
 def __init__(self, name='HttpRunner', logger=None) -> object:
     """
     HttpRunner constructor
     :param name: the name of the class
     :param logger: logger from the framework
     """
     super(HttpRunner, self).__init__(name, logger)
     self.config = ConfigParser()
     self.target_host = self.config.get_target_host_name()
     self.target_port = self.config.get_target_port()
     self.http_get = self.config.get_http_get_method()
     self.http_post_put = self.config.get_http_post_put_method()
     self.http_post_update = self.config.get_http_post_update_method()
     self.http_delete = self.config.get_http_delete_method()
     self.http_fuzz_protocol = self.config.get_http_fuzz_protocol()
     self.http_path = self.config.get_http_path()
     self.http_content_type = self.config.get_http_content_type()
     self.http_payload = self.config.get_http_payload()
     self.gen_uuid = GenerateUUID.generate_uuid()