def test_tiny(self): self.assertEqual(len(self.target.segments), 1) self.assertEqual(self.target.segments[0].virtual_address, 0x100000000) self.assertEqual(self.target.segments[0].file_offset, 0) self.assertEqual(self.target.segments[0].physical_size, 0x17fffff2) self.assertEqual(len(self.target.segments[0].content), 84) if is_64bits_platform(): self.assertEqual(lief.hash(self.target.segments[0].content), 18446744073657409468)
def test_resource_dialogs(self): evince_path = get_sample('PE/PE32_x86_binary_EvincePortable.zip') evince: lief.PE.Binary = None with zipfile.ZipFile(evince_path, "r") as inz: for f in inz.infolist(): if f.filename != "EvincePortable/EvincePortable.exe": continue fbytes = inz.read(f.filename) evince = lief.parse(fbytes) manager = evince.resources_manager self.assertEqual(lief.hash(manager.manifest), 0x762c0ae9) self.assertEqual(len(manager.dialogs), 15) dialog = manager.dialogs[0] self.assertEqual(dialog.help_id, 0x1) self.assertEqual(dialog.x, 0x0) self.assertEqual(dialog.y, 0x0) self.assertEqual(dialog.cx, 0x118) self.assertEqual(dialog.cy, 0xa2) self.assertEqual(dialog.title, "") self.assertEqual(dialog.typeface, "MS Shell Dlg") self.assertEqual(dialog.weight, 0x0) self.assertEqual(dialog.point_size, 0x8) self.assertEqual(dialog.charset, 0x1) self.assertEqual(dialog.style, 0x0) self.assertEqual(dialog.lang, lief.PE.RESOURCE_LANGS.ENGLISH) self.assertEqual(dialog.sub_lang, lief.PE.RESOURCE_SUBLANGS.ENGLISH_US) self.assertEqual(len(dialog.items), 6) self.assertEqual(dialog.items[0].help_id, 0x0) self.assertEqual(dialog.items[0].extended_style, 0x0) self.assertEqual(dialog.items[0].style, 0x40030000) self.assertEqual(dialog.items[0].x, 0xab) self.assertEqual(dialog.items[0].y, 0x8e) self.assertEqual(dialog.items[0].cx, 0x32) self.assertEqual(dialog.items[0].cy, 0xe) self.assertEqual(dialog.items[0].id, 0x3) self.assertEqual(dialog.items[0].title, "") self.assertEqual(dialog.items[1].help_id, 0x0) self.assertEqual(dialog.items[1].extended_style, 0x0) self.assertEqual(dialog.items[1].style, 0x50010000) self.assertEqual(dialog.items[1].x, 0xdf) self.assertEqual(dialog.items[1].y, 0x8e) self.assertEqual(dialog.items[1].cx, 0x32) self.assertEqual(dialog.items[1].cy, 0xe) self.assertEqual(dialog.items[1].id, 0x1) self.assertEqual(dialog.items[1].title, "") self.assertEqual(dialog.items[2].help_id, 0x0) self.assertEqual(dialog.items[2].extended_style, 0x0) self.assertEqual(dialog.items[2].style, 0x50010000) self.assertEqual(dialog.items[2].x, 0x7) self.assertEqual(dialog.items[2].y, 0x8e) self.assertEqual(dialog.items[2].cx, 0x32) self.assertEqual(dialog.items[2].cy, 0xe) self.assertEqual(dialog.items[2].id, 0x2) self.assertEqual(dialog.items[2].title, "") self.assertEqual(dialog.items[5].help_id, 0x0) self.assertEqual(dialog.items[5].extended_style, 0x0) self.assertEqual(dialog.items[5].style, 0x58020001) self.assertEqual(dialog.items[5].x, 0x3b) self.assertEqual(dialog.items[5].y, 0x91) self.assertEqual(dialog.items[5].cx, 0x6c) self.assertEqual(dialog.items[5].cy, 0x8) self.assertEqual(dialog.items[5].id, 0x404) self.assertEqual(dialog.items[5].title, "")
def test_dex_files(self): telecom = lief.VDEX.parse( get_sample('VDEX/VDEX_06_AArch64_Telecom.vdex')) h = hash(telecom.dex_files[0]) h_file = lief.hash(telecom.dex_files[0].raw(False)) h_file_dopt = lief.hash(telecom.dex_files[0].raw(True))
def test_sections(): sections = winhello64.sections assert len(sections) == 17 section = sections[4] assert section.name == ".xdata" assert section.offset == 0x3200 assert section.size == 0x400 assert section.virtual_address == 0x6000 assert section.virtual_size == 0x204 assert section.characteristics == 0x40300040 sections = atapi.sections assert sections[0].name == ".text" assert sections[0].virtual_size == 0x2be4 assert sections[0].virtual_address == 0x1000 assert sections[0].sizeof_raw_data == 0x2c00 assert sections[0].pointerto_raw_data == 0x400 assert sections[0].pointerto_relocation == 0x0 assert sections[0].pointerto_line_numbers == 0x0 assert sections[0].numberof_relocations == 0x0 assert sections[0].numberof_line_numbers == 0x0 assert int(sections[0].characteristics) == 0x68000020 if is_64bits_platform(): assert lief.hash(list(sections[0].padding)) == 0xffffffffc691aee8 assert lief.hash(list(sections[0].content)) == 0x2023e2e assert sections[1].name == ".rdata" assert sections[1].virtual_size == 0x2b4 assert sections[1].virtual_address == 0x4000 assert sections[1].sizeof_raw_data == 0x400 assert sections[1].pointerto_raw_data == 0x3000 assert sections[1].pointerto_relocation == 0x0 assert sections[1].pointerto_line_numbers == 0x0 assert sections[1].numberof_relocations == 0x0 assert sections[1].numberof_line_numbers == 0x0 assert int(sections[1].characteristics) == 0x48000040 if is_64bits_platform(): assert lief.hash(list(sections[1].padding)) == 0xffffffffdc061565 assert lief.hash(list(sections[1].content)) == 0x7f4ae4d9 assert sections[2].name == ".data" assert sections[2].virtual_size == 0x114 assert sections[2].virtual_address == 0x5000 assert sections[2].sizeof_raw_data == 0x200 assert sections[2].pointerto_raw_data == 0x3400 assert sections[2].pointerto_relocation == 0x0 assert sections[2].pointerto_line_numbers == 0x0 assert sections[2].numberof_relocations == 0x0 assert sections[2].numberof_line_numbers == 0x0 assert int(sections[2].characteristics) == 0xc8000040 if is_64bits_platform(): assert lief.hash(list(sections[2].padding)) == 0x391e5290 assert lief.hash(list(sections[2].content)) == 0x2109ac81 assert sections[3].name == ".pdata" assert sections[3].virtual_size == 0x1e0 assert sections[3].virtual_address == 0x6000 assert sections[3].sizeof_raw_data == 0x200 assert sections[3].pointerto_raw_data == 0x3600 assert sections[3].pointerto_relocation == 0x0 assert sections[3].pointerto_line_numbers == 0x0 assert sections[3].numberof_relocations == 0x0 assert sections[3].numberof_line_numbers == 0x0 assert int(sections[3].characteristics) == 0x48000040 if is_64bits_platform(): assert lief.hash(list(sections[3].padding)) == 0xd5f2925 assert lief.hash(list(sections[3].content)) == 0x13f38a3e assert sections[4].name == "INIT" assert sections[4].virtual_size == 0x42a assert sections[4].virtual_address == 0x7000 assert sections[4].sizeof_raw_data == 0x600 assert sections[4].pointerto_raw_data == 0x3800 assert sections[4].pointerto_relocation == 0x0 assert sections[4].pointerto_line_numbers == 0x0 assert sections[4].numberof_relocations == 0x0 assert sections[4].numberof_line_numbers == 0x0 assert int(sections[4].characteristics) == 0xe2000020 if is_64bits_platform(): assert lief.hash(list(sections[4].padding)) == 0xffffffff93471cc1 assert lief.hash(list(sections[4].content)) == 0xffffffffb3ea2b8b assert sections[5].name == ".rsrc" assert sections[5].virtual_size == 0x3f0 assert sections[5].virtual_address == 0x8000 assert sections[5].sizeof_raw_data == 0x400 assert sections[5].pointerto_raw_data == 0x3e00 assert sections[5].pointerto_relocation == 0x0 assert sections[5].pointerto_line_numbers == 0x0 assert sections[5].numberof_relocations == 0x0 assert sections[5].numberof_line_numbers == 0x0 assert int(sections[5].characteristics) == 0x42000040 if is_64bits_platform(): assert lief.hash(list(sections[5].padding)) == 0x28ec37bb assert lief.hash(list(sections[5].content)) == 0x65f49890