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


Python common.HashList类代码示例

本文整理汇总了Python中cybox.common.HashList的典型用法代码示例。如果您正苦于以下问题:Python HashList类的具体用法?Python HashList怎么用?Python HashList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_namespace_count

    def test_namespace_count(self):
        h = HashList()
        h.append(EMPTY_MD5)
        h.append(EMPTY_SHA1)
        h.append(EMPTY_SHA224)
        h.append(EMPTY_SHA256)
        h.append(EMPTY_SHA384)
        h.append(EMPTY_SHA512)
        logger.info(h.to_xml())

        ns_list = cybox.test.round_trip(h, list_=True)._get_namespaces()
        logger.info(ns_list)

        # Only "common" and "vocabs" should be here. "xsi" is only added later
        self.assertEqual(2, len(ns_list))
开发者ID:aravindpfpt,项目名称:python-cybox,代码行数:15,代码来源:hash_test.py

示例2: from_dict

    def from_dict(file_dict, file_class=None):
        if not file_dict:
            return None
        if not file_class:
            file_ = File()
        else:
            file_ = file_class
        ObjectProperties.from_dict(file_dict, file_)

        file_.is_packed = file_dict.get('is_packed')
        file_.file_name = String.from_dict(file_dict.get('file_name'))
        file_.file_path = FilePath.from_dict(file_dict.get('file_path'))
        file_.device_path = String.from_dict(file_dict.get('device_path'))
        file_.full_path = String.from_dict(file_dict.get('full_path'))
        file_.file_extension = String.from_dict(file_dict.get('file_extension'))
        file_.size_in_bytes = UnsignedLong.from_dict(file_dict.get('size_in_bytes'))
        file_.magic_number = HexBinary.from_dict(file_dict.get('magic_number'))
        file_.file_format = String.from_dict(file_dict.get('file_format'))
        file_.hashes = HashList.from_list(file_dict.get('hashes'))
        file_.extracted_features = ExtractedFeatures.from_dict(file_dict.get('extracted_features'))
        file_.modified_time = String.from_dict(file_dict.get('modified_time'))
        file_.accessed_time = String.from_dict(file_dict.get('accessed_time'))
        file_.created_time = DateTime.from_dict(file_dict.get('created_time'))

        return file_
开发者ID:maurakilleen,项目名称:crits_dependencies,代码行数:25,代码来源:file_object.py

示例3: from_obj

    def from_obj(file_obj, file_class=None):
        if not file_obj:
            return None
        if not file_class:
            file_ = File()
        else:
            file_ = file_class
        ObjectProperties.from_obj(file_obj, file_)

        file_.is_packed = file_obj.get_is_packed()
        file_.file_name = String.from_obj(file_obj.get_File_Name())
        file_.file_path = FilePath.from_obj(file_obj.get_File_Path())
        file_.device_path = String.from_obj(file_obj.get_Device_Path())
        file_.full_path = String.from_obj(file_obj.get_Full_Path())
        file_.file_extension = String.from_obj(file_obj.get_File_Extension())
        file_.size_in_bytes = UnsignedLong.from_obj(file_obj.get_Size_In_Bytes())
        file_.magic_number = HexBinary.from_obj(file_obj.get_Magic_Number())
        file_.file_format = String.from_obj(file_obj.get_File_Format())
        file_.hashes = HashList.from_obj(file_obj.get_Hashes())
        file_.extracted_features = ExtractedFeatures.from_obj(file_obj.get_Extracted_Features())
        #TODO: why are there two Strings and one DateTime here?
        file_.modified_time = String.from_obj(file_obj.get_Modified_Time())
        file_.accessed_time = String.from_obj(file_obj.get_Accessed_Time())
        file_.created_time = DateTime.from_obj(file_obj.get_Created_Time())

        return file_
开发者ID:maurakilleen,项目名称:crits_dependencies,代码行数:26,代码来源:file_object.py

示例4: test_hashlist_set_get

    def test_hashlist_set_get(self):
        md5_hash = "25BA4574F3090456C1AAE37F4D2D59B8"
        sha256_hash = "B64C18B336A8319EFAC43FE5E6DB78B0969E696C1C149BA56CFD69CE72F1898F"
        sha512_hash = "2A3459EE6C2FC3D7533F2D1AF6963A21337552D4ACD52D76A09B53BF36A27C3C357F1B41952582CFD0EDC7F8AEFC6DC939C38DF4CCED0F57320AB3480EC042D9"
        ssdeep_hash = "3:AXGBicFlgVNhBGcL6wCrFQEv:AXGHsNhxLsr2C"

        h = HashList()
        
        h.ssdeep = ssdeep_hash
        h.md5 = md5_hash
        h.sha256 = sha256_hash
        h.sha512 = sha512_hash

        self.assertEqual(h.md5, md5_hash)
        self.assertEqual(h.sha256, sha256_hash)
        self.assertEqual(h.sha512, sha512_hash)
        self.assertEqual(h.ssdeep, ssdeep_hash)
开发者ID:CybOXProject,项目名称:python-cybox,代码行数:17,代码来源:hash_test.py

示例5: dict_from_object

 def dict_from_object(cls, byterun_obj):
     """Parse and return a dictionary for a ByteRun object"""
     byterun_dict = {}
     if byterun_obj.get_Offset() is not None: byterun_dict['offset'] = Base_Object_Attribute.dict_from_object(byterun_obj.get_Offset())
     if byterun_obj.get_File_System_Offset() is not None: byterun_dict['file_system_offset'] = Base_Object_Attribute.dict_from_object(byterun_obj.get_File_System_Offset())  
     if byterun_obj.get_Image_Offset() is not None: byterun_dict['image_offset'] = Base_Object_Attribute.dict_from_object(byterun_obj.get_Image_Offset())
     if byterun_obj.get_Length() is not None: byterun_dict['length'] = Base_Object_Attribute.dict_from_object(byterun_obj.get_Length())
     if byterun_obj.get_Hashes() is not None: byterun_dict['hashes'] = HashList.dict_from_object(byterun_obj.get_Hashes())
     if byterun_obj.get_Byte_Run_Data() is not None: byterun_dict['byte_run_data'] = {'value' : byterun_obj.get_Byte_Run_Data()}
     return byterun_dict
开发者ID:2xyo,项目名称:python-cybox,代码行数:10,代码来源:byterun.py

示例6: dict_from_object

 def dict_from_object(cls, defined_object):
     """Parse and return a dictionary for a Memory Object object"""
     defined_object_dict = {}
     if defined_object.get_is_injected() is not None: defined_object_dict['is_injected'] = {'value' : defined_object.get_is_injected()}
     if defined_object.get_is_mapped() is not None: defined_object_dict['is_mapped'] = {'value' : defined_object.get_is_mapped()}
     if defined_object.get_is_protected() is not None: defined_object_dict['is_protected'] = {'value' : defined_object.get_is_protected()}
     if defined_object.get_Hashes() is not None: defined_object_dict['hashes'] = HashList.dict_from_object(defined_object.get_Hashes())
     if defined_object.get_Name() is not None: defined_object_dict['name'] = Base_Object_Attribute.dict_from_object(defined_object.get_Name())
     if defined_object.get_Region_Size() is not None: defined_object_dict['region_size'] = Base_Object_Attribute.dict_from_object(defined_object.get_Region_Size())
     if defined_object.get_Region_Start_Address() is not None: defined_object_dict['region_start_address'] = Base_Object_Attribute.dict_from_object(defined_object.get_Region_Start_Address())
     return defined_object_dict
开发者ID:2xyo,项目名称:python-cybox,代码行数:11,代码来源:memory_object.py

示例7: from_dict

    def from_dict(extracted_string_dict):
        if not extracted_string_dict:
            return None

        extracted_string_ = ExtractedString()
        extracted_string_.encoding = VocabString.from_dict(extracted_string_dict.get('encoding'))
        extracted_string_.string_value = String.from_dict(extracted_string_dict.get('string_value'))
        extracted_string_.byte_string_value = HexBinary.from_dict(extracted_string_dict.get('byte_string_value'))
        extracted_string_.hashes = HashList.from_list(extracted_string_dict.get('hashes'))
        extracted_string_.address = HexBinary.from_dict(extracted_string_dict.get('address'))
        extracted_string_.length = PositiveInteger.from_dict(extracted_string_dict.get('length'))
        extracted_string_.language = String.from_dict(extracted_string_dict.get('language'))
        extracted_string_.english_translation = String.from_dict(extracted_string_dict.get('english_translation'))

        return extracted_string_
开发者ID:maurakilleen,项目名称:crits_dependencies,代码行数:15,代码来源:extracted_string.py

示例8: from_dict

    def from_dict(memory_dict):
        if not memory_dict:
            return None

        memory_ = Memory()
        memory_.is_injected = memory_dict.get('is_injected')
        memory_.is_mapped = memory_dict.get('is_mapped')
        memory_.is_protected = memory_dict.get('is_protected')
        memory_.hashes = HashList.from_list(memory_dict.get('hashes'))
        memory_.name = String.from_dict(memory_dict.get('name'))
        memory_.region_size = UnsignedLong.from_dict(memory_dict.get('region_size'))
        memory_.region_start_address = HexBinary.from_dict(memory_dict.get('region_start_address'))
        memory_.extracted_features = None

        return memory_
开发者ID:maurakilleen,项目名称:crits_dependencies,代码行数:15,代码来源:memory_object.py

示例9: from_obj

    def from_obj(memory_obj):
        if not memory_obj:
            return None

        memory_ = Memory()
        memory_.is_injected = memory_obj.get_is_injected()
        memory_.is_mapped = memory_obj.get_is_mapped()
        memory_.is_protected = memory_obj.get_is_protected()
        memory_.hashes = HashList.from_obj(memory_obj.get_Hashes())
        memory_.name = String.from_obj(memory_obj.get_Name())
        memory_.region_size = UnsignedLong.from_obj(memory_obj.get_Region_Size())
        memory_.region_start_address = HexBinary.from_obj(memory_obj.get_Region_Start_Address())
        memory_.extracted_features = None

        return memory_
开发者ID:maurakilleen,项目名称:crits_dependencies,代码行数:15,代码来源:memory_object.py

示例10: from_obj

    def from_obj(extracted_string_obj):
        if not extracted_string_obj:
            return None

        extracted_string_ = ExtractedString()
        extracted_string_.encoding = VocabString.from_obj(extracted_string_obj.get_Encoding())
        extracted_string_.string_value = String.from_obj(extracted_string_obj.get_String_Value())
        extracted_string_.byte_string_value = HexBinary.from_obj(extracted_string_obj.get_Byte_String_Value())
        extracted_string_.hashes = HashList.from_obj(extracted_string_obj.get_Hashes())
        extracted_string_.address = HexBinary.from_obj(extracted_string_obj.get_Address())
        extracted_string_.length = PositiveInteger.from_obj(extracted_string_obj.get_Length())
        extracted_string_.language = String.from_obj(extracted_string_obj.get_Language())
        extracted_string_.english_translation = String.from_obj(extracted_string_obj.get_English_Translation())

        return extracted_string_
开发者ID:maurakilleen,项目名称:crits_dependencies,代码行数:15,代码来源:extracted_string.py

示例11: object_from_dict

 def object_from_dict(cls, byterun_dict):
     """Create the ByteRun object representation from an input dictionary"""
     byterun_obj = common_types_binding.ByteRunType()
     for key, value in byterun_dict.items():
         if key == 'offset' :
             byterun_obj.set_Offset(Base_Object_Attribute.object_from_dict(common_types_binding.IntegerObjectAttributeType(datatype='Integer'),value))
         elif key == 'file_system_offset' :
             byterun_obj.set_File_System_Offset(Base_Object_Attribute.object_from_dict(common_types_binding.IntegerObjectAttributeType(datatype='Integer'),value))
         elif key == 'image_offset' :
             byterun_obj.set_Image_Offset(Base_Object_Attribute.object_from_dict(common_types_binding.IntegerObjectAttributeType(datatype='Integer'),value))
         elif key == 'length' :
             byterun_obj.set_Offset(Base_Object_Attribute.object_from_dict(common_types_binding.IntegerObjectAttributeType(datatype='Integer'),value))
         elif key == 'hashes' :
             byterun_obj.set_Hashes(HashList.object_from_dict(value))
         elif key == 'byte_run_data':
             byterun_obj.set_Byte_Run_Data(value)
     return byterun_obj
开发者ID:2xyo,项目名称:python-cybox,代码行数:17,代码来源:byterun.py

示例12: object_from_dict

    def object_from_dict(cls, memory_attributes):
        """Create the Memory Object object representation from an input dictionary"""
        mem_object = memory_binding.MemoryObjectType()
        mem_object.set_anyAttributes_({'xsi:type' : 'MemoryObj:MemoryObjectType'})
        for key,value in memory_attributes.items():
            if key == 'is_injected' and utils.test_value(value): mem_object.set_is_injected(value.get('value'))
            elif key == 'is_mapped' and utils.test_value(value): mem_object.set_is_mapped(value.get('value'))
            elif key == 'is_protected' and utils.test_value(value): mem_object.set_is_injected(value.get('value'))
            elif key == 'region_start_address' and utils.test_value(value):
                mem_object.set_Region_Start_Address(Base_Object_Attribute.object_from_dict(common_types_binding.HexBinaryObjectAttributeType(datatype='hexBinary'),value))
            elif key == 'region_size' and utils.test_value(value):
                mem_object.set_Region_Size(Base_Object_Attribute.object_from_dict(common_types_binding.UnsignedLongObjectAttributeType(datatype='UnsignedLong'),value))            
            elif key == 'name' and utils.test_value(value):
                mem_object.set_Name(Base_Object_Attribute.object_from_dict(common_types_binding.StringObjectAttributeType(datatype='String'),value))          
            elif key == 'hashes':
                mem_object.set_Hashes(HashList.object_from_dict(value))

        return mem_object
开发者ID:2xyo,项目名称:python-cybox,代码行数:18,代码来源:memory_object.py

示例13: from_dict

    def from_dict(file_dict):
        if not file_dict:
            return None

        file_ = File()

        file_.is_packed = file_dict.get('is_packed')
        file_.file_name = String.from_dict(file_dict.get('file_name'))
        file_.file_path = FilePath.from_dict(file_dict.get('file_path'))
        file_.device_path = String.from_dict(file_dict.get('device_path'))
        file_.full_path = String.from_dict(file_dict.get('full_path'))
        file_.file_extension = String.from_dict(file_dict.get('file_extension'))
        file_.size_in_bytes = UnsignedLong.from_dict(file_dict.get('size_in_bytes'))
        file_.magic_number = HexBinary.from_dict(file_dict.get('magic_number'))
        file_.file_format = String.from_dict(file_dict.get('file_format'))
        file_.hashes = HashList.from_dict(file_dict.get('hashes'))

        return file_
开发者ID:2xyo,项目名称:python-cybox,代码行数:18,代码来源:file_object.py

示例14: from_obj

    def from_obj(file_obj):
        if not file_obj:
            return None

        file_ = File()

        file_.is_packed = file_obj.get_is_packed()
        file_.file_name = String.from_obj(file_obj.get_File_Name())
        file_.file_path = FilePath.from_obj(file_obj.get_File_Path())
        file_.device_path = String.from_obj(file_obj.get_Device_Path())
        file_.full_path = String.from_obj(file_obj.get_Full_Path())
        file_.file_extension = String.from_obj(file_obj.get_File_Extension())
        file_.size_in_bytes = UnsignedLong.from_obj(file_obj.get_Size_In_Bytes())
        file_.magic_number = HexBinary.from_obj(file_obj.get_Magic_Number())
        file_.file_format = String.from_obj(file_obj.get_File_Format())
        file_.hashes = HashList.from_obj(file_obj.get_Hashes())

        return file_
开发者ID:2xyo,项目名称:python-cybox,代码行数:18,代码来源:file_object.py

示例15: from_dict

    def from_dict(toolinfo_dict, toolinfo=None):
        if not toolinfo_dict:
            return None

        if not toolinfo:
            toolinfo = ToolInformation()

        toolinfo.id_ = toolinfo_dict.get('id')
        toolinfo.idref = toolinfo_dict.get('idref')
        toolinfo.name = toolinfo_dict.get('name')
        toolinfo.type_ = [VocabString.from_dict(x) for x in toolinfo_dict.get('type', [])]
        toolinfo.description = StructuredText.from_dict(toolinfo_dict.get('description'))

        toolinfo.vendor = toolinfo_dict.get('vendor')
        toolinfo.version = toolinfo_dict.get('version')
        toolinfo.service_pack = toolinfo_dict.get('service_pack')

        toolinfo.tool_hashes = HashList.from_list(toolinfo_dict.get('tool_hashes'))

        return toolinfo
开发者ID:pallav17,项目名称:python-cybox,代码行数:20,代码来源:tools.py


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