|
|
|
@ -1588,17 +1588,21 @@ def jemalloc_find_extent(addr) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
addr = int(addr)
|
|
|
|
addr = int(addr)
|
|
|
|
|
|
|
|
|
|
|
|
rtree = jemalloc.RTree.get_rtree()
|
|
|
|
try:
|
|
|
|
extent = rtree.lookup_hard(addr)
|
|
|
|
rtree = jemalloc.RTree.get_rtree()
|
|
|
|
if extent is None:
|
|
|
|
extent = rtree.lookup_hard(addr)
|
|
|
|
print(message.error("ERROR: Extent not found"))
|
|
|
|
if extent is None:
|
|
|
|
return
|
|
|
|
print(message.error("ERROR: Extent not found"))
|
|
|
|
# print pointer address first, then extent address then extent information
|
|
|
|
return
|
|
|
|
print(f"Pointer Address: {hex(addr)}")
|
|
|
|
# print pointer address first, then extent address then extent information
|
|
|
|
print(f"Extent Address: {hex(extent.extent_address)}")
|
|
|
|
print(f"Pointer Address: {hex(addr)}")
|
|
|
|
print()
|
|
|
|
print(f"Extent Address: {hex(extent.extent_address)}")
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
|
|
jemalloc_extent_info(extent.extent_address, header=False)
|
|
|
|
jemalloc_extent_info(extent.extent_address, header=False)
|
|
|
|
|
|
|
|
except pwndbg.dbg_mod.Error as e:
|
|
|
|
|
|
|
|
print(message.error(f"ERROR: {e}"))
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description="Prints extent information for the given address")
|
|
|
|
parser = argparse.ArgumentParser(description="Prints extent information for the given address")
|
|
|
|
@ -1609,25 +1613,30 @@ parser.add_argument(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.HEAP)
|
|
|
|
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.HEAP)
|
|
|
|
def jemalloc_extent_info(addr, verbose=False, header=True) -> None:
|
|
|
|
def jemalloc_extent_info(addr, verbose=False, header=True) -> bool:
|
|
|
|
if header:
|
|
|
|
if header:
|
|
|
|
print(C.banner("Jemalloc extent info"))
|
|
|
|
print(C.banner("Jemalloc extent info"))
|
|
|
|
print("This command was tested only for jemalloc 5.3.0 and does not support lower versions")
|
|
|
|
print("This command was tested only for jemalloc 5.3.0 and does not support lower versions")
|
|
|
|
print()
|
|
|
|
print()
|
|
|
|
|
|
|
|
|
|
|
|
extent = jemalloc.Extent(int(addr))
|
|
|
|
try:
|
|
|
|
|
|
|
|
extent = jemalloc.Extent(int(addr))
|
|
|
|
|
|
|
|
|
|
|
|
print(f"Allocated Address: {hex(extent.allocated_address)}")
|
|
|
|
print(f"Allocated Address: {hex(extent.allocated_address)}")
|
|
|
|
print(f"Extent Address: {hex(extent.extent_address)}")
|
|
|
|
print(f"Extent Address: {hex(extent.extent_address)}")
|
|
|
|
|
|
|
|
|
|
|
|
print(f"Size: {hex(extent.size)}")
|
|
|
|
print(f"Size: {hex(extent.size)}")
|
|
|
|
print(f"Small class: {extent.has_slab}")
|
|
|
|
print(f"Small class: {extent.has_slab}")
|
|
|
|
|
|
|
|
|
|
|
|
print(f"State: {extent.state_name}")
|
|
|
|
print(f"State: {extent.state_name}")
|
|
|
|
|
|
|
|
|
|
|
|
if verbose:
|
|
|
|
if verbose:
|
|
|
|
for bit, val in extent.bitfields.items():
|
|
|
|
for bit, val in extent.bitfields.items():
|
|
|
|
print(bit, val)
|
|
|
|
print(bit, val)
|
|
|
|
|
|
|
|
except pwndbg.dbg_mod.Error as e:
|
|
|
|
|
|
|
|
print(message.error(f"ERROR: {e}"))
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description="Prints all extents information")
|
|
|
|
parser = argparse.ArgumentParser(description="Prints all extents information")
|
|
|
|
@ -1641,17 +1650,15 @@ def jemalloc_heap() -> None:
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
rtree = jemalloc.RTree.get_rtree()
|
|
|
|
rtree = jemalloc.RTree.get_rtree()
|
|
|
|
except pwndbg.dbg_mod.Error as what:
|
|
|
|
extents = rtree.extents
|
|
|
|
# Fixes test_commands[jemalloc_heap] test case
|
|
|
|
if len(extents) == 0:
|
|
|
|
print(message.warn(f"{what}"))
|
|
|
|
print(message.warn("No extents found"))
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
for extent in extents:
|
|
|
|
extents = rtree.extents
|
|
|
|
# TODO: refactor so not create copies
|
|
|
|
if len(extents) == 0:
|
|
|
|
if not jemalloc_extent_info(extent.extent_address, header=False):
|
|
|
|
print(message.warn("No extents found"))
|
|
|
|
return
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
except pwndbg.dbg_mod.Error as e:
|
|
|
|
|
|
|
|
print(message.error(f"ERROR: {e}"))
|
|
|
|
return
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
|
|
for extent in extents:
|
|
|
|
|
|
|
|
# TODO: refactor so not create copies
|
|
|
|
|
|
|
|
jemalloc_extent_info(extent.extent_address, header=False)
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
|