MCPcopy Create free account
hub / github.com/qilingframework/qiling / ELFTest

Class ELFTest

tests/test_elf.py:30–832  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29
30class ELFTest(unittest.TestCase):
31
32 def test_libpatch_elf_linux_x8664(self):
33 ql = Qiling(["../examples/rootfs/x8664_linux/bin/patch_test.bin"], "../examples/rootfs/x8664_linux")
34 ql.patch(0x0000000000000575, b'qiling\x00', target='libpatch_test.so')
35 ql.run()
36 del ql
37
38 def test_elf_freebsd_x8664(self):
39 ql = Qiling(["../examples/rootfs/x8664_freebsd/bin/x8664_hello_asm"], "../examples/rootfs/x8664_freebsd", verbose=QL_VERBOSE.DUMP)
40 ql.run()
41 del ql
42
43 def test_elf_partial_linux_x8664(self):
44 snapshot_file = r'/tmp/snapshot.bin'
45
46 def dump(ql: Qiling, *args, **kw):
47 ql.save(reg=False, cpu_context=True, snapshot=snapshot_file)
48 ql.emu_stop()
49
50 ql = Qiling(["../examples/rootfs/x8664_linux/bin/sleep_hello"], "../examples/rootfs/x8664_linux", verbose=QL_VERBOSE.DEFAULT)
51 load_address = ql.profile.getint("OS64", "load_address")
52 ql.hook_address(dump, load_address + 0x1094)
53 ql.run()
54
55 ql = Qiling(["../examples/rootfs/x8664_linux/bin/sleep_hello"], "../examples/rootfs/x8664_linux", verbose=QL_VERBOSE.DEBUG)
56 load_address = ql.profile.getint("OS64", "load_address")
57 ql.restore(snapshot=snapshot_file)
58
59 begin_point = load_address + 0x109e
60 end_point = load_address + 0x10bc
61
62 ql.run(begin_point, end_point)
63
64 del ql
65
66 def test_elf_x_only_segment(self):
67 def stop(ql: Qiling):
68 ql.emu_stop()
69
70 ql = Qiling(["../examples/rootfs/x8664_linux/bin/sleep_hello_with_x_only_segment"], "../examples/rootfs/x8664_linux", verbose=QL_VERBOSE.DEBUG)
71 load_address = ql.profile.getint("OS64", "load_address")
72 ql.hook_address(stop, load_address + 0x1094)
73 ql.run()
74
75 del ql
76
77 def _test_elf_linux_x86_snapshot_restore_common(self, reg=False, ctx=False):
78 rootfs = "../examples/rootfs/x86_linux"
79 cmdline = ["../examples/rootfs/x86_linux/bin/x86_hello"]
80 snapshot = os.path.join(rootfs, 'snapshot_restore_reg_ctx.snapshot')
81
82 ql = Qiling(cmdline, rootfs, verbose=QL_VERBOSE.DEBUG)
83
84 load_address = ql.profile.getint("OS32", "load_address")
85 hook_address = load_address + 0x542 # call printf
86
87 def dump(ql: Qiling):

Callers 1

populate_testsFunction · 0.70

Calls

no outgoing calls

Tested by 1

populate_testsFunction · 0.56