From d2ac1430b8fecdbdeb972b8f4b54dcb55d703bc3 Mon Sep 17 00:00:00 2001 From: k4lizen <124312252+k4lizen@users.noreply.github.com> Date: Fri, 9 May 2025 16:13:16 +0200 Subject: [PATCH] Show aliases in command help and docs (#2960) * print aliases with command help * show alias in docs; singular if there is only one alias * autogen docs * remove dot from alias line * autogen docs --- docs/commands/breakpoint/breakrva.md | 2 ++ docs/commands/context/context.md | 2 ++ docs/commands/context/contextnext.md | 2 ++ docs/commands/context/contextoutput.md | 2 ++ docs/commands/context/contextprev.md | 2 ++ docs/commands/context/contextsearch.md | 2 ++ docs/commands/context/contextunwatch.md | 2 ++ docs/commands/context/contextwatch.md | 2 ++ docs/commands/disassemble/nearpc.md | 2 ++ docs/commands/glibc_ptmalloc2_heap/vis-heap-chunks.md | 2 ++ docs/commands/integrations/bn-sync.md | 2 ++ docs/commands/integrations/r2.md | 2 ++ docs/commands/integrations/rop.md | 2 ++ docs/commands/integrations/rz.md | 2 ++ docs/commands/linux_libc_elf/envp.md | 2 ++ docs/commands/memory/go-dump.md | 2 ++ docs/commands/memory/go-type.md | 2 ++ docs/commands/memory/vmmap.md | 2 ++ docs/commands/misc/down.md | 2 ++ docs/commands/misc/dumpargs.md | 2 ++ docs/commands/process/pid.md | 2 ++ docs/commands/register/cpsr.md | 2 ++ docs/commands/register/setflag.md | 2 ++ docs/commands/start/start.md | 2 ++ docs/commands/step_next_continue/nextjmp.md | 2 ++ docs/commands/step_next_continue/nextsyscall.md | 2 ++ docs/commands/step_next_continue/stepover.md | 2 ++ docs/commands/step_next_continue/stepsyscall.md | 2 ++ docs/commands/windbg/dds.md | 2 ++ pwndbg/commands/__init__.py | 5 +++++ scripts/_gen_command_docs.py | 4 ++++ 31 files changed, 67 insertions(+) diff --git a/docs/commands/breakpoint/breakrva.md b/docs/commands/breakpoint/breakrva.md index c07516278..73c88d9a2 100644 --- a/docs/commands/breakpoint/breakrva.md +++ b/docs/commands/breakpoint/breakrva.md @@ -12,6 +12,8 @@ usage: breakrva [-h] [offset] [module] ``` Break at RVA from PIE base. + +**Alias:** brva ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/context/context.md b/docs/commands/context/context.md index f70c46de5..c09e8a143 100644 --- a/docs/commands/context/context.md +++ b/docs/commands/context/context.md @@ -12,6 +12,8 @@ usage: context [-h] [--on] [--off] [subcontext ...] ``` Print out the current register, instruction, and stack context. + +**Alias:** ctx ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/context/contextnext.md b/docs/commands/context/contextnext.md index 84de3ced8..7b0f5db4f 100644 --- a/docs/commands/context/contextnext.md +++ b/docs/commands/context/contextnext.md @@ -12,6 +12,8 @@ usage: contextnext [-h] [count] ``` Select next entry in context history. + +**Alias:** ctxn ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/context/contextoutput.md b/docs/commands/context/contextoutput.md index cb1e35339..458388c7a 100644 --- a/docs/commands/context/contextoutput.md +++ b/docs/commands/context/contextoutput.md @@ -12,6 +12,8 @@ usage: contextoutput [-h] section path clearing [banner] [width] ``` Sets the output of a context section. + +**Alias:** ctx-out ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/context/contextprev.md b/docs/commands/context/contextprev.md index 7fc152337..1ed975978 100644 --- a/docs/commands/context/contextprev.md +++ b/docs/commands/context/contextprev.md @@ -12,6 +12,8 @@ usage: contextprev [-h] [count] ``` Select previous entry in context history. + +**Alias:** ctxp ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/context/contextsearch.md b/docs/commands/context/contextsearch.md index f7aecf3f9..106a5af64 100644 --- a/docs/commands/context/contextsearch.md +++ b/docs/commands/context/contextsearch.md @@ -12,6 +12,8 @@ usage: contextsearch [-h] needle [section] ``` Search for a string in the context history and select that entry. + +**Alias:** ctxsearch ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/context/contextunwatch.md b/docs/commands/context/contextunwatch.md index 4db48f704..e5a2717d0 100644 --- a/docs/commands/context/contextunwatch.md +++ b/docs/commands/context/contextunwatch.md @@ -12,6 +12,8 @@ usage: contextunwatch [-h] num ``` Removes an expression previously added to be watched. + +**Aliases:** ctx-unwatch, cunwatch ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/context/contextwatch.md b/docs/commands/context/contextwatch.md index 5a7cadece..0fc1ca1e2 100644 --- a/docs/commands/context/contextwatch.md +++ b/docs/commands/context/contextwatch.md @@ -14,6 +14,8 @@ usage: contextwatch [-h] [{eval,execute}] expression Adds an expression to be shown on context. To remove an expression, see `cunwatch`. + +**Aliases:** ctx-watch, cwatch ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/disassemble/nearpc.md b/docs/commands/disassemble/nearpc.md index 36dfe3483..261c252c7 100644 --- a/docs/commands/disassemble/nearpc.md +++ b/docs/commands/disassemble/nearpc.md @@ -12,6 +12,8 @@ usage: nearpc [-h] [-e] [pc] [lines] ``` Disassemble near a specified address. + +**Aliases:** pdisass, u ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/glibc_ptmalloc2_heap/vis-heap-chunks.md b/docs/commands/glibc_ptmalloc2_heap/vis-heap-chunks.md index d8f935cfc..6940e7b10 100644 --- a/docs/commands/glibc_ptmalloc2_heap/vis-heap-chunks.md +++ b/docs/commands/glibc_ptmalloc2_heap/vis-heap-chunks.md @@ -15,6 +15,8 @@ usage: vis-heap-chunks [-h] [--beyond_top] [--no_truncate] [--all_chunks] Visualize chunks on a heap. Default to the current arena's active heap. + +**Alias:** vis ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/integrations/bn-sync.md b/docs/commands/integrations/bn-sync.md index 2d0184775..b2afd70cd 100644 --- a/docs/commands/integrations/bn-sync.md +++ b/docs/commands/integrations/bn-sync.md @@ -12,6 +12,8 @@ usage: bn-sync [-h] ``` Synchronize Binary Ninja's cursor with GDB. + +**Alias:** bns ### Optional arguments |Short|Long|Help| diff --git a/docs/commands/integrations/r2.md b/docs/commands/integrations/r2.md index e211dd42c..48dd4bac6 100644 --- a/docs/commands/integrations/r2.md +++ b/docs/commands/integrations/r2.md @@ -12,6 +12,8 @@ usage: r2 [-h] [--no-seek] [--no-rebase] [arguments ...] ``` Launches radare2. + +**Alias:** radare2 ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/integrations/rop.md b/docs/commands/integrations/rop.md index b72f45328..d06c4ac1a 100644 --- a/docs/commands/integrations/rop.md +++ b/docs/commands/integrations/rop.md @@ -12,6 +12,8 @@ usage: rop [-h] [--grep GREP] [--memlimit MEMLIMIT] [argument ...] ``` Dump ROP gadgets with Jon Salwan's ROPgadget tool. + +**Alias:** ropgadget ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/integrations/rz.md b/docs/commands/integrations/rz.md index 102a07e76..9d423277e 100644 --- a/docs/commands/integrations/rz.md +++ b/docs/commands/integrations/rz.md @@ -12,6 +12,8 @@ usage: rz [-h] [--no-seek] [--no-rebase] [arguments ...] ``` Launches rizin. + +**Alias:** rizin ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/linux_libc_elf/envp.md b/docs/commands/linux_libc_elf/envp.md index c7569ff33..ab12b418a 100644 --- a/docs/commands/linux_libc_elf/envp.md +++ b/docs/commands/linux_libc_elf/envp.md @@ -12,6 +12,8 @@ usage: envp [-h] [name] ``` Prints out the contents of the environment. + +**Aliases:** env, environ ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/memory/go-dump.md b/docs/commands/memory/go-dump.md index 84c6f2dec..41e20111f 100644 --- a/docs/commands/memory/go-dump.md +++ b/docs/commands/memory/go-dump.md @@ -12,6 +12,8 @@ usage: go-dump [-h] [-x] [-f [DECIMALS]] [-d] [-p] ty address ``` Dumps a Go value of a given type at a specified address. + +**Alias:** god ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/memory/go-type.md b/docs/commands/memory/go-type.md index df3d6bebe..0c5a042de 100644 --- a/docs/commands/memory/go-type.md +++ b/docs/commands/memory/go-type.md @@ -12,6 +12,8 @@ usage: go-type [-h] address ``` Dumps a Go runtime reflection type at a specified address. + +**Alias:** goty ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/memory/vmmap.md b/docs/commands/memory/vmmap.md index 0bf36d488..ab61c0645 100644 --- a/docs/commands/memory/vmmap.md +++ b/docs/commands/memory/vmmap.md @@ -29,6 +29,8 @@ As a last resort, we sometimes try to explore the addresses in CPU registers and Memory pages can also be added manually with the use of vmmap-add, vmmap-clear and vmmap-load commands. This may be useful for bare metal debugging. [0] https://lore.kernel.org/all/20220221030910.3203063-1-dominik.b.czarnota@gmail.com/ + +**Aliases:** lm, address, vprot, libs ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/misc/down.md b/docs/commands/misc/down.md index 32e029dfd..2b85250f0 100644 --- a/docs/commands/misc/down.md +++ b/docs/commands/misc/down.md @@ -12,6 +12,8 @@ usage: down [-h] [n] ``` Select and print stack frame called by this one. + +**Aliases:** do, dow ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/misc/dumpargs.md b/docs/commands/misc/dumpargs.md index 4bda00a90..e0f8f5dec 100644 --- a/docs/commands/misc/dumpargs.md +++ b/docs/commands/misc/dumpargs.md @@ -12,6 +12,8 @@ usage: dumpargs [-h] [-f] ``` Prints determined arguments for call instruction. + +**Alias:** args ### Optional arguments |Short|Long|Help| diff --git a/docs/commands/process/pid.md b/docs/commands/process/pid.md index 4fc0807b2..c3decc752 100644 --- a/docs/commands/process/pid.md +++ b/docs/commands/process/pid.md @@ -12,6 +12,8 @@ usage: pid [-h] ``` Gets the pid. + +**Alias:** getpid ### Optional arguments |Short|Long|Help| diff --git a/docs/commands/register/cpsr.md b/docs/commands/register/cpsr.md index f0f44d55d..2aaa74449 100644 --- a/docs/commands/register/cpsr.md +++ b/docs/commands/register/cpsr.md @@ -12,6 +12,8 @@ usage: cpsr [-h] [cpsr_value] ``` Print out ARM CPSR or xPSR register. + +**Aliases:** xpsr, pstate ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/register/setflag.md b/docs/commands/register/setflag.md index 257f99fb6..7231ca0cf 100644 --- a/docs/commands/register/setflag.md +++ b/docs/commands/register/setflag.md @@ -12,6 +12,8 @@ usage: setflag [-h] flag value ``` Modify the flags register. + +**Alias:** flag ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/start/start.md b/docs/commands/start/start.md index a3cdc4360..848ba93de 100644 --- a/docs/commands/start/start.md +++ b/docs/commands/start/start.md @@ -25,6 +25,8 @@ With no arguments, uses arguments last specified (with "run" or use "set args" without arguments. To start the inferior without using a shell, use "set startup-with-shell off". + +**Aliases:** main, init ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/step_next_continue/nextjmp.md b/docs/commands/step_next_continue/nextjmp.md index 6d4c60ff3..653025747 100644 --- a/docs/commands/step_next_continue/nextjmp.md +++ b/docs/commands/step_next_continue/nextjmp.md @@ -12,6 +12,8 @@ usage: nextjmp [-h] ``` Breaks at the next jump instruction. + +**Alias:** nextjump ### Optional arguments |Short|Long|Help| diff --git a/docs/commands/step_next_continue/nextsyscall.md b/docs/commands/step_next_continue/nextsyscall.md index 03cf4eac1..857e0e398 100644 --- a/docs/commands/step_next_continue/nextsyscall.md +++ b/docs/commands/step_next_continue/nextsyscall.md @@ -12,6 +12,8 @@ usage: nextsyscall [-h] ``` Breaks at the next syscall not taking branches. + +**Alias:** nextsc ### Optional arguments |Short|Long|Help| diff --git a/docs/commands/step_next_continue/stepover.md b/docs/commands/step_next_continue/stepover.md index 267f4a2b0..a5118162a 100644 --- a/docs/commands/step_next_continue/stepover.md +++ b/docs/commands/step_next_continue/stepover.md @@ -12,6 +12,8 @@ usage: stepover [-h] [addr] ``` Breaks on the instruction after this one. + +**Alias:** so ### Positional arguments |Positional Argument|Help| diff --git a/docs/commands/step_next_continue/stepsyscall.md b/docs/commands/step_next_continue/stepsyscall.md index 48596dbd8..d2f1696c6 100644 --- a/docs/commands/step_next_continue/stepsyscall.md +++ b/docs/commands/step_next_continue/stepsyscall.md @@ -12,6 +12,8 @@ usage: stepsyscall [-h] ``` Breaks at the next syscall by taking branches. + +**Alias:** stepsc ### Optional arguments |Short|Long|Help| diff --git a/docs/commands/windbg/dds.md b/docs/commands/windbg/dds.md index ba132148f..8bba5002e 100644 --- a/docs/commands/windbg/dds.md +++ b/docs/commands/windbg/dds.md @@ -12,6 +12,8 @@ usage: dds [-h] addr ``` Dump pointers and symbols at the specified address. + +**Aliases:** kd, dps, dqs ### Positional arguments |Positional Argument|Help| diff --git a/pwndbg/commands/__init__.py b/pwndbg/commands/__init__.py index 29f9010f5..22c3cd005 100644 --- a/pwndbg/commands/__init__.py +++ b/pwndbg/commands/__init__.py @@ -266,6 +266,11 @@ class CommandObj: self.epilog += "\n" + self.pure_epilog + "\n" + if self.aliases: + alias_txt = "Alias" + ("es" if len(self.aliases) > 1 else "") + ": " + self.epilog += "\n" + message.notice(alias_txt) + self.epilog += ", ".join(self.aliases) + "\n" + # Update the parser so the help is correctly generated. self.parser.epilog = self.epilog = self.epilog.strip() diff --git a/scripts/_gen_command_docs.py b/scripts/_gen_command_docs.py index 29d53ac94..468f9ab17 100644 --- a/scripts/_gen_command_docs.py +++ b/scripts/_gen_command_docs.py @@ -120,6 +120,10 @@ def convert_to_markdown(filename: str, command: CommandObj) -> str: mdFile.insert_code(parser.format_usage(), language="text") # description mdFile.new_paragraph(description + "\n") + # aliases + if command.aliases: + alias_txt = "Alias" + ("es" if len(command.aliases) > 1 else "") + ":" + mdFile.write(f"\n**{alias_txt}** " + ", ".join(command.aliases) + "\n") used_actions = {} positionals = ["Positional Argument", "Help"]