Exemplo n.º 1
0
    def _make_run_prepereations(self):
        """
        Preparations which take place in the loading process.
        """
        redb_client_utils._parse_config_file()
        self._collect_string_addresses()
        self._collect_imported_modules()

        # Main dictionary holding all handled functions information.
        # The keys are the functions' first addresses.
        # The values are REDB_Functions - one for each handled function.
        self._handled_functions = {}

        idaapi.hide_wait_box()
Exemplo n.º 2
0
    def _make_run_prepereations(self):
        """
        Preparations which take place in the loading process.
        """
        redb_client_utils._parse_config_file()
        self._collect_string_addresses()
        self._collect_imported_modules()

        # Main dictionary holding all handled functions information.
        # The keys are the functions' first addresses.
        # The values are REDB_Functions - one for each handled function.
        self._handled_functions = {}

        idaapi.hide_wait_box()
Exemplo n.º 3
0
def send_submit(submit):
    """
    Given a jsoned Submit instance, sends it.
    """
    parse_config = redb_client_utils._parse_config_file()

    retval = post_multipart(parse_config.host, "/submit/", [],
                            [("pickled_submit", "pickled_submit", submit)])
    # handle response
    if retval:
        print "REDB: Uploaded description to server successfully."
    else:
        print "REDB: An error occurred while submitting descriptions!"
Exemplo n.º 4
0
    def request_descriptions(self):
        """
        Request descriptions for a function.
        """
        # Reset public descriptions
        self._public_descriptions = []

        parse_config = redb_client_utils._parse_config_file()
        max_descriptions_returned = parse_config.max_descriptions_returned

        request = redb_client_com.Request(self._primary_attributes,
                                          self._filtering_attributes,
                                          self._matching_grade_attributes,
                                          max_descriptions_returned)

        response = redb_client_com.send_request(request.to_json())

        if response != None:
            for suggested_description_dict in response.suggested_descriptions:
                # generate suggested description object
                # from suggested description dictionray recieved.
                suggested_description = \
                    redb_client_descriptions.SuggestedDecsription()
                suggested_description.from_dict(suggested_description_dict)

                # generate local description from suggested description.
                local_description = \
                    redb_client_descriptions.LocalDescription(self._first_addr)
                local_description.load_suggested(suggested_description)

                self._public_descriptions.append(local_description)

            self._num_of_pub_desc = len(self._public_descriptions)

            print ("REDB: Received " + str(self._num_of_pub_desc) +
                   " public descriptions.")

            if self._num_of_pub_desc:
                self._current_description.remove_desc()
                self._public_desc_index = 0
                self._current_description = \
                    self._public_descriptions[self._public_desc_index]
                self._current_description.\
                    show_desc(index=(self._public_desc_index + 1),
                              outof=self._num_of_pub_desc)
        else:
            print "REDB: No reply or an error occurred!"
Exemplo n.º 5
0
    def request_descriptions(self):
        """
        Request descriptions for a function.
        """
        # Reset public descriptions
        self._public_descriptions = []

        parse_config = redb_client_utils._parse_config_file()
        max_descriptions_returned = parse_config.max_descriptions_returned

        request = redb_client_com.Request(self._primary_attributes,
                                          self._filtering_attributes,
                                          self._matching_grade_attributes,
                                          max_descriptions_returned)

        response = redb_client_com.send_request(request.to_json())

        if response != None:
            for suggested_description_dict in response.suggested_descriptions:
                # generate suggested description object
                # from suggested description dictionray recieved.
                suggested_description = \
                    redb_client_descriptions.SuggestedDecsription()
                suggested_description.from_dict(suggested_description_dict)

                # generate local description from suggested description.
                local_description = \
                    redb_client_descriptions.LocalDescription(self._first_addr)
                local_description.load_suggested(suggested_description)

                self._public_descriptions.append(local_description)

            self._num_of_pub_desc = len(self._public_descriptions)

            print("REDB: Received " + str(self._num_of_pub_desc) +
                  " public descriptions.")

            if self._num_of_pub_desc:
                self._current_description.remove_desc()
                self._public_desc_index = 0
                self._current_description = \
                    self._public_descriptions[self._public_desc_index]
                self._current_description.\
                    show_desc(index=(self._public_desc_index + 1),
                              outof=self._num_of_pub_desc)
        else:
            print "REDB: No reply or an error occurred!"
Exemplo n.º 6
0
def send_request(request):
    """
    Given a jsoned Request instance, sends it. Returns a Response instance.
    """
    response = None
    parse_config = redb_client_utils._parse_config_file()

    try:
        response = Response()
        response.from_json(
            post_multipart(parse_config.host, "/request/", [],
                           [("pickled_request", "pickled_request", request)]))

    except:
        print "REDB: An error occurred while requesting descriptions!"
        response = None

    return response
Exemplo n.º 7
0
def send_submit(submit):
    """
    Given a jsoned Submit instance, sends it.
    """
    parse_config = redb_client_utils._parse_config_file()

    retval = post_multipart(parse_config.host,
                            "/submit/",
                            [],
                            [("pickled_submit",
                              "pickled_submit",
                              submit)]
                            )
    # handle response
    if retval:
        print "REDB: Uploaded description to server successfully."
    else:
        print "REDB: An error occurred while submitting descriptions!"
Exemplo n.º 8
0
def send_request(request):
    """
    Given a jsoned Request instance, sends it. Returns a Response instance.
    """
    response = None
    parse_config = redb_client_utils._parse_config_file()

    try:
        response = Response()
        response.from_json(post_multipart(parse_config.host,
                                         "/request/",
                                         [],
                                         [("pickled_request",
                                           "pickled_request",
                                           request)]
                                         ))

    except:
        print "REDB: An error occurred while requesting descriptions!"
        response = None

    return response