当前位置: 首页>>代码示例>>Python>>正文


Python AbstractType.normalize方法代码示例

本文整理汇总了Python中netzob.Common.Models.Types.AbstractType.AbstractType.normalize方法的典型用法代码示例。如果您正苦于以下问题:Python AbstractType.normalize方法的具体用法?Python AbstractType.normalize怎么用?Python AbstractType.normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在netzob.Common.Models.Types.AbstractType.AbstractType的用法示例。


在下文中一共展示了AbstractType.normalize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: searchDataInMessage

# 需要导入模块: from netzob.Common.Models.Types.AbstractType import AbstractType [as 别名]
# 或者: from netzob.Common.Models.Types.AbstractType.AbstractType import normalize [as 别名]
    def searchDataInMessage(self, data, message, addTags=True, dataLabels=None):
        """Search in the specified message any of the given data. These data will be searched as
        it but also under various format.

        >>> from netzob.all import *
        >>> message = RawMessage("Reversing protocols with Netzob")
        >>> sData = [ASCII("protocol")]
        >>> se = SearchEngine()
        >>> results = se.searchDataInMessage(sData, message)
        >>> print results
        1 occurence(s) found.
        >>> for result in results:
        ...    print result
        ...    print repr(result.searchTask.properties["data"])
        Found ascii-bits(bigEndian) at [(80L, 144L)] of bitarray('01010010011001010111011001100101011100100111001101101001011011100110011100100000011100000111001001101111011101000110111101100011011011110110110001110011001000000111011101101001011101000110100000100000010011100110010101110100011110100110111101100010')
        protocol


        :parameter data: the data to search after. Data must be provided with their netzob type.
        :type data: a list of :class:`netzob.Common.Models.Types.AbstractType.AbstractType`.
        :parameter message: the message in which the search will take place
        :type message: :class:`netzob.Common.Models.Vocabulary.Messages.AbstractMessage`
        :keyword addTags: if set to True, visualization functions are added to the message to highlights found results.
        :type addTags: :class:`bool`
        :keyword dataLabels: an optionnal dict to attach to each data a label to simplify search results identification
        :type dataLabels: dict

        :return: a search results detailling where and how occurrences where found. Occurences are also
        identified in the message through dedicated visualization functions automaticaly added to the message.
        :rtype: :class:`netzob.Inference.Vocabulary.SearchEngine.SearchResults.SearchResults`

        """

        if data is None or len(data) == 0:
            raise TypeError("At least one data should be specified.")

        if message is None:
            raise TypeError("Message cannot be None")

        searchTasks = []
        for d in data:
            # normalize the given data
            normedData = AbstractType.normalize(d)

            # build search tasks
            props = dict()
            props['message'] = message
            props['data'] = d
            if dataLabels is not None and d in dataLabels.keys():
                props['label'] = dataLabels[d]

            searchTasks.extend(self.__buildSearchTasks(normedData, props))

        # fetch the content of the message and convert it to bitarray
        target = TypeConverter.convert(message.data, Raw, BitArray)

        # Generate search cases
        searchCases = itertools.product([target], searchTasks)

        searchResults = self.__search(searchCases)

        # If requested, we tag the results in the message using visualization functions
        # if addTags:
        #     for searchResult in searchResults:
        #         for (startPos, endPos) in searchResult.ranges:
        #             self._logger.info("function from {} to {}".format(startPos, endPos))
        #             message.visualizationFunctions.append(HighlightFunction(startPos, endPos))
        return searchResults
开发者ID:chubbymaggie,项目名称:netzob,代码行数:70,代码来源:SearchEngine.py

示例2: __normalizeLeafDomain

# 需要导入模块: from netzob.Common.Models.Types.AbstractType import AbstractType [as 别名]
# 或者: from netzob.Common.Models.Types.AbstractType.AbstractType import normalize [as 别名]
 def __normalizeLeafDomain(domain):
     if isinstance(domain, (Data, AbstractRelationVariableLeaf)):
         return domain
     else:
         return AbstractType.normalize(domain).buildDataRepresentation()
开发者ID:chubbymaggie,项目名称:netzob,代码行数:7,代码来源:DomainFactory.py


注:本文中的netzob.Common.Models.Types.AbstractType.AbstractType.normalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。