|
|
|
@ -10,6 +10,7 @@ import pwndbg.commands
|
|
|
|
import pwndbg.hexdump
|
|
|
|
import pwndbg.hexdump
|
|
|
|
from pwndbg.color import message
|
|
|
|
from pwndbg.color import message
|
|
|
|
from pwndbg.commands import CommandCategory
|
|
|
|
from pwndbg.commands import CommandCategory
|
|
|
|
|
|
|
|
from pwndbg.lib.config import PARAM_ZUINTEGER
|
|
|
|
|
|
|
|
|
|
|
|
pwndbg.config.add_param("hexdump-width", 16, "line width of hexdump command")
|
|
|
|
pwndbg.config.add_param("hexdump-width", 16, "line width of hexdump command")
|
|
|
|
pwndbg.config.add_param("hexdump-bytes", 64, "number of bytes printed by hexdump command")
|
|
|
|
pwndbg.config.add_param("hexdump-bytes", 64, "number of bytes printed by hexdump command")
|
|
|
|
@ -25,6 +26,16 @@ pwndbg.config.add_param(
|
|
|
|
help_docstring="When `on`, use big-endian within each group of bytes. Only applies to raw bytes, not the ASCII part. "
|
|
|
|
help_docstring="When `on`, use big-endian within each group of bytes. Only applies to raw bytes, not the ASCII part. "
|
|
|
|
"See also hexdump-highlight-group-lsb.",
|
|
|
|
"See also hexdump-highlight-group-lsb.",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
pwndbg.config.add_param(
|
|
|
|
|
|
|
|
"hexdump-limit-mb",
|
|
|
|
|
|
|
|
10,
|
|
|
|
|
|
|
|
"the maximum size in megabytes (MB) `hexdump` will read",
|
|
|
|
|
|
|
|
help_docstring="""Set the maximum size in megabytes (MB) that the `hexdump` command will attempt to read at once.
|
|
|
|
|
|
|
|
Prevents GDB crashes due to excessive memory allocation requests.
|
|
|
|
|
|
|
|
Set to 0 for unlimited (use with caution).""",
|
|
|
|
|
|
|
|
param_class=PARAM_ZUINTEGER,
|
|
|
|
|
|
|
|
scope="memory",
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def address_or_module_name(s) -> int:
|
|
|
|
def address_or_module_name(s) -> int:
|
|
|
|
@ -76,6 +87,20 @@ def hexdump(address, count=pwndbg.config.hexdump_bytes) -> None:
|
|
|
|
address = new_address
|
|
|
|
address = new_address
|
|
|
|
|
|
|
|
|
|
|
|
count = max(int(count), 0)
|
|
|
|
count = max(int(count), 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get the configured limit in MB
|
|
|
|
|
|
|
|
limit_mb = int(pwndbg.config.hexdump_limit_mb)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check if the limit is enabled (non-zero) and if the request count exceeds it
|
|
|
|
|
|
|
|
if limit_mb > 0:
|
|
|
|
|
|
|
|
limit_bytes = limit_mb * 1024 * 1024
|
|
|
|
|
|
|
|
if count > limit_bytes:
|
|
|
|
|
|
|
|
# Raise an error with the informative message
|
|
|
|
|
|
|
|
raise ValueError(
|
|
|
|
|
|
|
|
f"Hexdump count ({count}) exceeds the current limit of {limit_mb} MB.\n"
|
|
|
|
|
|
|
|
f"Use 'set hexdump-limit-mb <new_limit_in_mb>' to increase the limit (or set to 0 for unlimited)."
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
width = int(pwndbg.config.hexdump_width)
|
|
|
|
width = int(pwndbg.config.hexdump_width)
|
|
|
|
|
|
|
|
|
|
|
|
group_width = int(pwndbg.config.hexdump_group_width)
|
|
|
|
group_width = int(pwndbg.config.hexdump_group_width)
|
|
|
|
|