|
|
|
|
@ -175,3 +175,30 @@ def test_command_buddydump():
|
|
|
|
|
assert f"Order {i}" not in filter_res
|
|
|
|
|
filter_res = gdb.execute("bud -p", to_string=True)
|
|
|
|
|
assert "free_area" not in filter_res
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.skipif(
|
|
|
|
|
pwndbg.aglib.arch.name not in ["i386", "x86-64"],
|
|
|
|
|
reason="pagewalk is only fully implemented for x86 (partially relies on cr3)",
|
|
|
|
|
)
|
|
|
|
|
def test_command_pagewalk():
|
|
|
|
|
address = pwndbg.aglib.kernel.kbase()
|
|
|
|
|
if address is None:
|
|
|
|
|
# no kbase? fine
|
|
|
|
|
pages = pwndbg.aglib.vmmap.get()
|
|
|
|
|
address = pages[0].start
|
|
|
|
|
res = gdb.execute(f"pagewalk {hex(address)}", to_string=True)
|
|
|
|
|
assert "PMD" in res # Page Size is only set for PMDe or PTe
|
|
|
|
|
res = res.splitlines()[-1]
|
|
|
|
|
match = re.find(r"0x[0-9a-fA-F]{16}", res)
|
|
|
|
|
physmap_addr = int(match, 16)
|
|
|
|
|
# compare the first 0x100 bytes of the page (e.g. first kernel image page) with its physmap conterpart
|
|
|
|
|
expected = pwndbg.aglib.memory.read(address, 0x100)
|
|
|
|
|
actual = pwndbg.aglib.memory.read(physmap_addr, 0x100)
|
|
|
|
|
assert all(expected[i] == actual[i] for i in range(0x100))
|
|
|
|
|
# make sure that when using cr3 for pgd, it still works
|
|
|
|
|
res2 = gdb.execute(f"pagewalk {address} --pgd $cr3", to_string=True)
|
|
|
|
|
assert res == res2
|
|
|
|
|
# test non nonexistent address
|
|
|
|
|
res = gdb.execute("pagewalk 0", to_string=True)
|
|
|
|
|
assert res == "address is not mapped"
|
|
|
|
|
|