def __searchApplicativeDataInMessage(self, message):
        """This internal method search any applicative data that could be identified
        in the specified message and returns results in a dict that shows the position
        of the applicative data identified.

        :parameter message: the message in which we search any applicative data
        :type message: :class:`netzob.Common.Models.Vocabulary.Messages.AbstractMessage.AbstractMessage`
        :return: a dict that describes the position of identified applicative data
        :rtype: :class:`dict`
        """
        if message is None:
            raise TypeError("Message cannot be None")

        self._logger.debug("Search app data in {0}".format(message.data))

        results = OrderedDict()

        appValues = OrderedDict()
        if message.session is not None:
            for applicativeD in message.session.applicativeData:
                appValues[applicativeD.value] = applicativeD.name
        else:
            self._logger.debug("Message is not attached to a session, so no applicative data will be considered while computing the alignment.")

        if len(appValues) > 0:
            searchResults = SearchEngine.searchInMessage(appValues.keys(), message, addTags=False)
            for searchResult in searchResults:
                for (startResultRange, endResultRange) in searchResult.ranges:
                    appDataName = appValues[searchResult.searchTask.properties["data"]]
                    for pos in range(startResultRange/4, endResultRange/4):
                        results[pos] = appDataName

        return results
Exemple #2
0
    def __searchApplicativeDataInMessage(self, message):
        """This internal method search any applicative data that could be identified
        in the specified message and returns results in a dict that shows the position
        of the applicative data identified.

        :parameter message: the message in which we search any applicative data
        :type message: :class:`netzob.Common.Models.Vocabulary.Messages.AbstractMessage.AbstractMessage`
        :return: a dict that describes the position of identified applicative data
        :rtype: :class:`dict`
        """
        if message is None:
            raise TypeError("Message cannot be None")

        self._logger.debug("Search app data in {0}".format(message.data))

        results = OrderedDict()

        appValues = OrderedDict()
        if message.session is not None:
            for applicativeD in message.session.applicativeData:
                appValues[applicativeD.value] = applicativeD.name
        else:
            self._logger.debug("Message is not attached to a session, so no applicative data will be considered while computing the alignment.")

        if len(appValues) > 0:
            searchResults = SearchEngine.searchInMessage(appValues.keys(), message, addTags=False)
            for searchResult in searchResults:
                for (startResultRange, endResultRange) in searchResult.ranges:
                    appDataName = appValues[searchResult.searchTask.properties["data"]]
                    for pos in range(startResultRange/4, endResultRange/4):
                        results[pos] = appDataName

        return results