From 63812e0043b592d3acff9df52959ad9679d29359 Mon Sep 17 00:00:00 2001 From: An0nAN4N7 <143926241+An0nAN4N7@users.noreply.github.com> Date: Wed, 16 Jul 2025 14:04:27 -0500 Subject: [PATCH] Add --show-all flag to cymbol to list all custom structure names (#3157) * Add --show-all flag to cymbol to list all custom structure names * Fix: Apply ruff formatting to cymbol.py * Fix: Regenerate cymbol docs for --show-all flag --------- Co-authored-by: parrot --- docs/commands/misc/cymbol.md | 3 ++- pwndbg/commands/cymbol.py | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/commands/misc/cymbol.md b/docs/commands/misc/cymbol.md index 4593718f5..c4c76a300 100644 --- a/docs/commands/misc/cymbol.md +++ b/docs/commands/misc/cymbol.md @@ -4,7 +4,7 @@ ```text usage: cymbol [-h] [-a name] [-f filepath] [-r name] [-e name] [-l name] - [-s name] + [-s name] [--show-all] ``` @@ -20,6 +20,7 @@ Add, show, load, edit, or delete custom structures in plain C. |-e|--edit|Edit an existing custom structure| |-l|--load|Load an existing custom structure| |-s|--show|Show the source code of an existing custom structure| +||--show-all|Show names of all available custom structures| diff --git a/pwndbg/commands/cymbol.py b/pwndbg/commands/cymbol.py index 192988067..073904f01 100644 --- a/pwndbg/commands/cymbol.py +++ b/pwndbg/commands/cymbol.py @@ -301,10 +301,17 @@ parser.add_argument( default=None, type=str, ) +parser.add_argument( + "--show-all", + help="Show names of all available custom structures", + action="store_true", +) @pwndbg.commands.Command(parser, category=CommandCategory.MISC) -def cymbol(add: str, file: str, remove: str, edit: str, load: str, show: str) -> None: +def cymbol( + add: str, file: str, remove: str, edit: str, load: str, show: str, show_all: bool +) -> None: if add: add_custom_structure(add) elif file: @@ -317,5 +324,11 @@ def cymbol(add: str, file: str, remove: str, edit: str, load: str, show: str) -> load_custom_structure(load) elif show: show_custom_structure(show) + elif show_all: + print(message.notice("Available custom structure names:\n")) + for file in os.listdir(pwndbg_cachedir): + if file.endswith(".c"): + name = os.path.splitext(file)[0] + print(f" - {name}") else: parser.print_help()