Remove shell commands and cleanup command parsing (#2919)

* cleanup the command parsing

* fix tests

* remove shell commands, refactor command logic

* update docs

* fix tests

* cleanup

* refactor alias logic

* fixup the rebase

* enforce consistent formatting
pull/2936/head
k4lizen 7 months ago committed by GitHub
parent b8c8e61a0a
commit afc2c83342
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -220,7 +220,7 @@ parser = argparse.ArgumentParser(description="Command description.")
parser.add_argument("arg", type=str, help="An example argument.")
@pwndbg.commands.ArgparsedCommand(parser)
@pwndbg.commands.Command(parser)
def my_command(arg: str) -> None:
"""Print the argument"""
print(f"Argument is {arg}")

@ -20,8 +20,8 @@ usage: breakrva [-h] [offset] [module]
|Positional Argument|Help|
| :--- | :--- |
|`offset`|Offset to add. (default: %(default)s)|
|`module`|Module to choose as base. Defaults to the target executable. (default: %(default)s)|
|`offset`|Offset to add.|
|`module`|Module to choose as base. Defaults to the target executable.|
## Optional Arguments

@ -20,7 +20,7 @@ usage: contextnext [-h] [count]
|Positional Argument|Help|
| :--- | :--- |
|`count`|The number of entries to go forward in history (default: %(default)s)|
|`count`|The number of entries to go forward in history|
## Optional Arguments

@ -23,7 +23,7 @@ usage: contextoutput [-h] section path clearing [banner] [width]
|`section`|The section which is to be configured. ('regs', 'disasm', 'code', 'stack', 'backtrace', 'ghidra', 'args', 'threads', 'heap_tracker', 'expressions', and/or 'last_signal')|
|`path`|The path to which the output is written|
|`clearing`|Indicates weather to clear the output|
|`banner`|Where a banner should be placed: both, top , bottom, none (default: %(default)s)|
|`banner`|Where a banner should be placed: both, top , bottom, none|
|`width`|Sets a fixed width (used for banner). Set to None for auto|
## Optional Arguments

@ -20,7 +20,7 @@ usage: contextprev [-h] [count]
|Positional Argument|Help|
| :--- | :--- |
|`count`|The number of entries to go back in history (default: %(default)s)|
|`count`|The number of entries to go back in history|
## Optional Arguments

@ -24,7 +24,7 @@ usage: contextwatch [-h] [{eval,execute}] expression
|Positional Argument|Help|
| :--- | :--- |
|`cmd`|Command to be used with the expression. - eval: the expression is parsed and evaluated as in the debugged language. - execute: the expression is executed as a GDB command. (default: %(default)s)|
|`cmd`|Command to be used with the expression. - eval: the expression is parsed and evaluated as in the debugged language. - execute: the expression is executed as a GDB command.|
|`expression`|The expression to be evaluated and shown in context|
## Optional Arguments

@ -27,8 +27,8 @@ usage: dev-dump-instruction [-h] [-e] [-n] [address]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-e`|`--emulate`||Force the use of emulation when enhancing the instruction, regardless of global 'emulate' setting. (default: %(default)s)|
|`-n`|`--no-emulate`||Disable the use of emulation when enhancing the instruction, regardless of global 'emulate' setting. (default: %(default)s)|
|`-e`|`--emulate`||Force the use of emulation when enhancing the instruction, regardless of global 'emulate' setting.|
|`-n`|`--no-emulate`||Disable the use of emulation when enhancing the instruction, regardless of global 'emulate' setting.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -20,7 +20,7 @@ usage: log-level [-h] [{debug,info,warning,error,critical}]
|Positional Argument|Help|
| :--- | :--- |
|`level`|The log level to set. (default: %(default)s)|
|`level`|The log level to set.|
## Optional Arguments

@ -28,7 +28,7 @@ usage: nearpc [-h] [-e] [pc] [lines]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-e`|`--emulate`||Whether to emulate instructions to find the next ones or just linearly disassemble. (default: %(default)s)|
|`-e`|`--emulate`||Whether to emulate instructions to find the next ones or just linearly disassemble.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -29,7 +29,7 @@ usage: fastbins [-h] [-v] [addr]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-v`|`--verbose`||Show all fastbins, including empty ones (default: %(default)s)|
|`-v`|`--verbose`||Show all fastbins, including empty ones|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -30,9 +30,9 @@ usage: find-fake-fast [-h] [--align] [--glibc-fastbin-bug]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-a`|`--align`||Whether the fake chunk must be aligned to MALLOC_ALIGNMENT. This is required for tcache chunks and for all chunks when Safe Linking is enabled (default: %(default)s)|
|`-b`|`--glibc-fastbin-bug`||Does the GLIBC fastbin size field bug affect the candidate size field width? (default: %(default)s)|
|`-p`|`--partial-overwrite`||Consider partial overwrite candidates, default behavior only shows word-size overwrites. (default: %(default)s)|
|`-a`|`--align`||Whether the fake chunk must be aligned to MALLOC_ALIGNMENT. This is required for tcache chunks and for all chunks when Safe Linking is enabled|
|`-b`|`--glibc-fastbin-bug`||Does the GLIBC fastbin size field bug affect the candidate size field width?|
|`-p`|`--partial-overwrite`||Consider partial overwrite candidates, default behavior only shows word-size overwrites.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -29,8 +29,8 @@ usage: heap [-h] [-v] [-s] [addr]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-v`|`--verbose`||Print all chunk fields, even unused ones. (default: %(default)s)|
|`-s`|`--simple`||Simply print malloc_chunk struct's contents. (default: %(default)s)|
|`-v`|`--verbose`||Print all chunk fields, even unused ones.|
|`-s`|`--simple`||Simply print malloc_chunk struct's contents.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -27,9 +27,9 @@ usage: hi [-h] [-v] [-s] [-f] addr
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-v`|`--verbose`||Print all chunk fields, even unused ones. (default: %(default)s)|
|`-s`|`--simple`||Simply print malloc_chunk struct's contents. (default: %(default)s)|
|`-f`|`--fake`||Allow fake chunks. If set, displays any memory as a heap chunk (even if its not a real chunk). (default: %(default)s)|
|`-v`|`--verbose`||Print all chunk fields, even unused ones.|
|`-s`|`--simple`||Simply print malloc_chunk struct's contents.|
|`-f`|`--fake`||Allow fake chunks. If set, displays any memory as a heap chunk (even if its not a real chunk).|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -29,7 +29,7 @@ usage: largebins [-h] [-v] [addr]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-v`|`--verbose`||Show all largebins, including empty ones (default: %(default)s)|
|`-v`|`--verbose`||Show all largebins, including empty ones|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -27,11 +27,11 @@ usage: malloc-chunk [-h] [-f] [-v] [-s] [-d] [-n NEXT] addr
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-f`|`--fake`||Is this a fake chunk? (default: %(default)s)|
|`-v`|`--verbose`||Print all chunk fields, even unused ones. (default: %(default)s)|
|`-s`|`--simple`||Simply print malloc_chunk struct's contents. (default: %(default)s)|
|`-d`|`--dump`||Print a hexdump of the chunk. (default: %(default)s)|
|`-n`|`--next`|`0`|Print the next N chunks after the specified address. (default: %(default)s)|
|`-f`|`--fake`||Is this a fake chunk?|
|`-v`|`--verbose`||Print all chunk fields, even unused ones.|
|`-s`|`--simple`||Simply print malloc_chunk struct's contents.|
|`-d`|`--dump`||Print a hexdump of the chunk.|
|`-n`|`--next`|`0`|Print the next N chunks after the specified address.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -29,7 +29,7 @@ usage: smallbins [-h] [-v] [addr]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-v`|`--verbose`||Show all smallbins, including empty ones (default: %(default)s)|
|`-v`|`--verbose`||Show all smallbins, including empty ones|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -29,7 +29,7 @@ usage: tcachebins [-h] [-v] [addr]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-v`|`--verbose`||Show all tcachebins, including empty ones (default: %(default)s)|
|`-v`|`--verbose`||Show all tcachebins, including empty ones|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -29,7 +29,7 @@ usage: unsortedbin [-h] [-v] [addr]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-v`|`--verbose`||Show the "all" bin even if it's empty (default: %(default)s)|
|`-v`|`--verbose`||Show the "all" bin even if it's empty|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -23,7 +23,7 @@ usage: vis-heap-chunks [-h] [--beyond_top] [--no_truncate] [--all_chunks]
|Positional Argument|Help|
| :--- | :--- |
|`count`|Number of chunks to visualize. If the value is big enough and addr isn't provided, this is interpreted as addr instead. (default: %(default)s)|
|`count`|Number of chunks to visualize. If the value is big enough and addr isn't provided, this is interpreted as addr instead.|
|`addr`|Address of the first chunk.|
## Optional Arguments
@ -31,9 +31,9 @@ usage: vis-heap-chunks [-h] [--beyond_top] [--no_truncate] [--all_chunks]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-b`|`--beyond_top`||Attempt to keep printing beyond the top chunk. (default: %(default)s)|
|`-n`|`--no_truncate`||Display all the chunk contents (Ignore the `max-visualize-chunk-size` configuration). (default: %(default)s)|
|`-a`|`--all_chunks`|| Display all chunks (Ignore the default-visualize-chunk-number configuration). (default: %(default)s)|
|`-b`|`--beyond_top`||Attempt to keep printing beyond the top chunk.|
|`-n`|`--no_truncate`||Display all the chunk contents (Ignore the `max-visualize-chunk-size` configuration).|
|`-a`|`--all_chunks`|| Display all chunks (Ignore the default-visualize-chunk-number configuration).|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -32,8 +32,8 @@ usage: ai [-h] [-M MODEL] [-t TEMPERATURE] [-m MAX_TOKENS] [-v] [-L]
|`-M`|`--model`|`None`|The OpenAI model to use.|
|`-t`|`--temperature`|`None`|The temperature to use.|
|`-m`|`--max-tokens`|`None`|The maximum number of tokens to generate.|
|`-v`|`--verbose`||Print the prompt and response. (default: %(default)s)|
|`-L`|`--list-models`||List the available models. (default: %(default)s)|
|`-v`|`--verbose`||Print the prompt and response.|
|`-L`|`--list-models`||List the available models.|
|`-c`|`--command`|`None`|Run a command in the GDB debugger and ask a question about the output.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->

@ -27,8 +27,8 @@ usage: r2 [-h] [--no-seek] [--no-rebase] [arguments ...]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
||`--no-seek`||Do not seek to current pc (default: %(default)s)|
||`--no-rebase`||Do not set the base address for PIE according to the current mapping (default: %(default)s)|
||`--no-seek`||Do not seek to current pc|
||`--no-rebase`||Do not set the base address for PIE according to the current mapping|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -28,7 +28,7 @@ usage: rop [-h] [--grep GREP] [--memlimit MEMLIMIT] [argument ...]
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
||`--grep`|`None`|String to grep the output for|
||`--memlimit`|`50MB`|String to grep the output for (default: %(default)s)|
||`--memlimit`|`50MB`|String to grep the output for|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -27,8 +27,8 @@ usage: rz [-h] [--no-seek] [--no-rebase] [arguments ...]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
||`--no-seek`||Do not seek to current pc (default: %(default)s)|
||`--no-rebase`||Do not set the base address for PIE according to the current mapping (default: %(default)s)|
||`--no-seek`||Do not seek to current pc|
||`--no-rebase`||Do not set the base address for PIE according to the current mapping|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -27,7 +27,7 @@ usage: jemalloc-extent-info [-h] [-v] addr
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-v`|`--verbose`||Print all chunk fields, even unused ones. (default: %(default)s)|
|`-v`|`--verbose`||Print all chunk fields, even unused ones.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -21,7 +21,7 @@ usage: kbase [-h] [-r]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-r`|`--rebase`||rebase loaded symbol file (default: %(default)s)|
|`-r`|`--rebase`||rebase loaded symbol file|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -27,16 +27,16 @@ usage: got [-h] [-p PATH_FILTER | -a] [-r] [symbol_filter]
|Positional Argument|Help|
| :--- | :--- |
|`symbol_filter`|Filter results by symbol name. (default: %(default)s)|
|`symbol_filter`|Filter results by symbol name.|
## Optional Arguments
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-p`|`--path`|``|Filter results by library/objfile path. (default: %(default)s)|
|`-a`|`--all`||Process all libs/obfjiles including the target executable. (default: %(default)s)|
|`-r`|`--show-readonly`||Also display read-only entries (which are filtered out by default). (default: %(default)s)|
|`-p`|`--path`|``|Filter results by library/objfile path.|
|`-a`|`--all`||Process all libs/obfjiles including the target executable.|
|`-r`|`--show-readonly`||Also display read-only entries (which are filtered out by default).|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -25,9 +25,9 @@ usage: onegadget [-h] [--show-unsat] [--no-unknown] [-v]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
||`--show-unsat`||Show unsatisfiable gadgets. (default: %(default)s)|
||`--no-unknown`||Do not show unknown gadgets. (default: %(default)s)|
|`-v`|`--verbose`||Show verbose output. (default: %(default)s)|
||`--show-unsat`||Show unsatisfiable gadgets.|
||`--no-unknown`||Do not show unknown gadgets.|
|`-v`|`--verbose`||Show verbose output.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -20,8 +20,8 @@ usage: piebase [-h] [offset] [module]
|Positional Argument|Help|
| :--- | :--- |
|`offset`|Offset from PIE base. (default: %(default)s)|
|`module`|Module to choose as base. Defaults to the target executable. (default: %(default)s)|
|`offset`|Offset from PIE base.|
|`module`|Module to choose as base. Defaults to the target executable.|
## Optional Arguments

@ -20,14 +20,14 @@ usage: strings [-h] [-n N] [--save-as SAVE_AS] [page_names ...]
|Positional Argument|Help|
| :--- | :--- |
|`page_names`|Mapping to search [e.g. libc]. Can be used with multiple mappings [e.g libc heap stack] (default: %(default)s)|
|`page_names`|Mapping to search [e.g. libc]. Can be used with multiple mappings [e.g libc heap stack]|
## Optional Arguments
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-n`||`4`|Minimum length of ASCII strings to include (default: %(default)s)|
|`-n`||`4`|Minimum length of ASCII strings to include|
||`--save-as`|`None`|Sets the filename for the output of this command [e.g. --save-as='out.txt']|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->

@ -27,7 +27,7 @@ usage: threads [-h] [-c] [num_threads]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-c`|`--config`||Respect context-max-threads config to limit number of threads displayed. (default: %(default)s)|
|`-c`|`--config`||Respect context-max-threads config to limit number of threads displayed.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -21,8 +21,8 @@ usage: tls [-h] [-p] [-a]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-p`|`--pthread-self`||Try to get the address of TLS by calling pthread_self(). (default: %(default)s)|
|`-a`|`--all`||Do not truncate the dump output. (default: %(default)s)|
|`-p`|`--pthread-self`||Try to get the address of TLS by calling pthread_self().|
|`-a`|`--all`||Do not truncate the dump output.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -29,7 +29,7 @@ usage: dump-register-frame [-h] [-p]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-p`|`--print`||Show addresses of frame values (default: %(default)s)|
|`-p`|`--print`||Show addresses of frame values|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -29,7 +29,7 @@ usage: gdt [-h] address [count]
|Positional Argument|Help|
| :--- | :--- |
|`address`|x86-64 GDTR base address (e.g. read from sgdt instruction from [16:79] bits)|
|`count`|Number of entries to dump (should be (GDTR.size+1)/8) (default: %(default)s)|
|`count`|Number of entries to dump (should be (GDTR.size+1)/8)|
## Optional Arguments

@ -28,10 +28,10 @@ usage: go-dump [-h] [-x] [-f [DECIMALS]] [-d] [-p] ty address
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-x`|`--hex`||Display non-pointer integers as hex (default: %(default)s)|
|`-x`|`--hex`||Display non-pointer integers as hex|
|`-f`|`--decimals`|`None`|Configures the number of decimal places to display for floating points|
|`-d`|`--debug`||Shows debug info, like addresses for slice/map elements, slice capacity, etc. (default: %(default)s)|
|`-p`|`--pretty`||Enables pretty printing (default: %(default)s)|
|`-d`|`--debug`||Shows debug info, like addresses for slice/map elements, slice capacity, etc.|
|`-p`|`--pretty`||Enables pretty printing|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -20,8 +20,8 @@ usage: hexdump [-h] [address] [count]
|Positional Argument|Help|
| :--- | :--- |
|`address`|Address or module name to dump (default: %(default)s)|
|`count`|Number of bytes to dump (default: %(default)s)|
|`address`|Address or module name to dump|
|`count`|Number of bytes to dump|
## Optional Arguments

@ -27,7 +27,7 @@ usage: leakfind [-h] [-p [PAGE_NAME]] [-o [MAX_OFFSET]] [-d [MAX_DEPTH]]
|Positional Argument|Help|
| :--- | :--- |
|`address`|Starting address to find a leak chain from (default: %(default)s)|
|`address`|Starting address to find a leak chain from|
## Optional Arguments
@ -35,10 +35,10 @@ usage: leakfind [-h] [-p [PAGE_NAME]] [-o [MAX_OFFSET]] [-d [MAX_DEPTH]]
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-p`|`--page_name`|`None`|Substring required to be part of the name of any found pages|
|`-o`|`--max_offset`|`72`|Max offset to add to addresses when looking for leak (default: %(default)s)|
|`-d`|`--max_depth`|`4`|Maximum depth to follow pointers to (default: %(default)s)|
|`-s`|`--step`|`1`|Step to add between pointers so they are considered. For example, if this is 4 it would only consider pointers at an offset divisible by 4 from the starting pointer (default: %(default)s)|
||`--negative_offset`|`0`|Max negative offset to search before an address when looking for a leak (default: %(default)s)|
|`-o`|`--max_offset`|`72`|Max offset to add to addresses when looking for leak|
|`-d`|`--max_depth`|`4`|Maximum depth to follow pointers to|
|`-s`|`--step`|`1`|Step to add between pointers so they are considered. For example, if this is 4 it would only consider pointers at an offset divisible by 4 from the starting pointer|
||`--negative_offset`|`0`|Max negative offset to search before an address when looking for a leak|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -49,18 +49,18 @@ usage: mmap [-h] [--quiet] [--force] addr length [prot] [flags] [fd] [offset]
| :--- | :--- |
|`addr`|Address hint to be given to mmap.|
|`length`|Length of the mapping, in bytes. Needs to be greater than zero.|
|`prot`|Prot enum or int as in mmap(2). Eg. "PROT_READ\|PROT_EXEC" or 7 (for RWX). (default: %(default)s)|
|`flags`|Flags enum or int as in mmap(2). Eg. "MAP_PRIVATE\|MAP_ANONYMOUS" or 0x22. (default: %(default)s)|
|`fd`|File descriptor of the file to be mapped, or -1 if using MAP_ANONYMOUS. (default: %(default)s)|
|`offset`|Offset from the start of the file, in bytes, if using file based mapping. (default: %(default)s)|
|`prot`|Prot enum or int as in mmap(2). Eg. "PROT_READ\|PROT_EXEC" or 7 (for RWX).|
|`flags`|Flags enum or int as in mmap(2). Eg. "MAP_PRIVATE\|MAP_ANONYMOUS" or 0x22.|
|`fd`|File descriptor of the file to be mapped, or -1 if using MAP_ANONYMOUS.|
|`offset`|Offset from the start of the file, in bytes, if using file based mapping.|
## Optional Arguments
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-q`|`--quiet`||Disable address validity warnings and hints (default: %(default)s)|
|`-f`|`--force`||Force potentially unsafe actions to happen (default: %(default)s)|
|`-q`|`--quiet`||Disable address validity warnings and hints|
|`-f`|`--force`||Force potentially unsafe actions to happen|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -28,17 +28,17 @@ usage: probeleak [-h] [--max-distance MAX_DISTANCE] [--point-to POINT_TO]
|Positional Argument|Help|
| :--- | :--- |
|`address`|Leak memory address (default: %(default)s)|
|`count`|Leak size in bytes (default: %(default)s)|
|`address`|Leak memory address|
|`count`|Leak size in bytes|
## Optional Arguments
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
||`--max-distance`|`0`|Max acceptable distance between memory page boundary and leaked pointer (default: %(default)s)|
||`--max-distance`|`0`|Max acceptable distance between memory page boundary and leaked pointer|
||`--point-to`|`None`|Mapping name of the page that you want the pointers point to|
||`--max-ptrs`|`0`|Stop search after find n pointers, default 0 (default: %(default)s)|
||`--max-ptrs`|`0`|Stop search after find n pointers, default 0|
||`--flags`|`None`|flags of the page that you want the pointers point to. [e.g. rwx]|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->

@ -37,7 +37,7 @@ usage: search [-h] [-t {byte,short,word,dword,qword,pointer,string,bytes,asm}]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-t`|`--type`|`bytes`|Size of search target (default: %(default)s)|
|`-t`|`--type`|`bytes`|Size of search target|
|`-1`|`--byte`|`None`|Search for a 1-byte integer|
|`-2`|`--short`|`None`|Search for a 2-byte integer|
|`-4`|`--dword`|`None`|Search for a 4-byte integer|
@ -45,17 +45,17 @@ usage: search [-h] [-t {byte,short,word,dword,qword,pointer,string,bytes,asm}]
|`-p`|`--pointer`|`None`|Search for a pointer-width integer|
||`--asm`|`None`|Search for an assembly instruction|
||`--arch`|`None`|Target architecture|
||`--asmbp`||Set breakpoint for found assembly instruction (default: %(default)s)|
|`-x`|`--hex`||Target is a hex-encoded (for bytes/strings) (default: %(default)s)|
|`-e`|`--executable`||Search executable segments only (default: %(default)s)|
|`-w`|`--writable`||Search writable segments only (default: %(default)s)|
||`--asmbp`||Set breakpoint for found assembly instruction|
|`-x`|`--hex`||Target is a hex-encoded (for bytes/strings)|
|`-e`|`--executable`||Search executable segments only|
|`-w`|`--writable`||Search writable segments only|
|`-s`|`--step`|`None`|Step search address forward to next alignment after each hit (ex: 0x1000)|
|`-l`|`--limit`|`None`|Max results before quitting the search. Differs from --trunc-out in that it will not save all search results before quitting|
|`-a`|`--aligned`|`None`|Result must be aligned to this byte boundary|
||`--save`|`None`|Save results for further searches with --next. Default comes from config 'auto-save-search'|
||`--no-save`|`None`|Invert --save|
|`-n`|`--next`||Search only locations returned by previous search with --save (default: %(default)s)|
||`--trunc-out`||Truncate the output to 20 results. Differs from --limit in that it will first save all search results (default: %(default)s)|
|`-n`|`--next`||Search only locations returned by previous search with --save|
||`--trunc-out`||Truncate the output to 20 results. Differs from --limit in that it will first save all search results|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -20,17 +20,17 @@ usage: telescope [-h] [-r] [-f] [-i] [address] [count]
|Positional Argument|Help|
| :--- | :--- |
|`address`|The address to telescope at. (default: %(default)s)|
|`count`|The number of lines to show. (default: %(default)s)|
|`address`|The address to telescope at.|
|`count`|The number of lines to show.|
## Optional Arguments
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-r`|`--reverse`||Show <count> previous addresses instead of next ones (default: %(default)s)|
|`-f`|`--frame`||Show the stack frame, from rsp to rbp (default: %(default)s)|
|`-i`|`--inverse`||Show the stack reverse growth (default: %(default)s)|
|`-r`|`--reverse`||Show <count> previous addresses instead of next ones|
|`-f`|`--frame`||Show the stack frame, from rsp to rbp|
|`-i`|`--inverse`||Show the stack reverse growth|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -22,8 +22,8 @@ usage: vmmap-add [-h] start size [flags] [offset]
| :--- | :--- |
|`start`|Starting virtual address|
|`size`|Size of the address space, in bytes|
|`flags`|Flags set by the ELF file (r - read, w - write, x - executable) (default: %(default)s)|
|`offset`|Offset into the original ELF file that the data is loaded from (default: %(default)s)|
|`flags`|Flags set by the ELF file (r - read, w - write, x - executable)|
|`offset`|Offset into the original ELF file that the data is loaded from|
## Optional Arguments

@ -44,12 +44,12 @@ usage: vmmap [-h] [-w] [-x] [-A LINES_AFTER] [-B LINES_BEFORE] [-C CONTEXT]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-w`|`--writable`||Display writable maps only (default: %(default)s)|
|`-x`|`--executable`||Display executable maps only (default: %(default)s)|
|`-A`|`--lines-after`|`1`|Number of pages to display after result (default: %(default)s)|
|`-B`|`--lines-before`|`1`|Number of pages to display before result (default: %(default)s)|
|`-w`|`--writable`||Display writable maps only|
|`-x`|`--executable`||Display executable maps only|
|`-A`|`--lines-after`|`1`|Number of pages to display after result|
|`-B`|`--lines-before`|`1`|Number of pages to display before result|
|`-C`|`--context`|`None`|Number of pages to display around the result|
||`--gaps`||Display unmapped memory gap information in the memory map. (default: %(default)s)|
||`--gaps`||Display unmapped memory gap information in the memory map.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -20,7 +20,7 @@ usage: xinfo [-h] [address]
|Positional Argument|Help|
| :--- | :--- |
|`address`|Address to inspect (default: %(default)s)|
|`address`|Address to inspect|
## Optional Arguments

@ -23,14 +23,14 @@ usage: asm [-h] [-f {hex,string}]
|Positional Argument|Help|
| :--- | :--- |
|`shellcode`|Assembler code to assemble (default: %(default)s)|
|`shellcode`|Assembler code to assemble|
## Optional Arguments
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-f`|`--format`|`hex`|Output format (default: %(default)s)|
|`-f`|`--format`|`hex`|Output format|
||`--arch`|`None`|Target architecture|
|`-v`|`--avoid`|`None`|Encode the shellcode to avoid the listed bytes (provided as hex)|
|`-n`|`--newline`|`None`|Encode the shellcode to avoid newlines|

@ -21,15 +21,15 @@ usage: cyclic [-h] [-a charset] [-n length] [-l lookup_value]
|Positional Argument|Help|
| :--- | :--- |
|`count`|Number of characters to print from the sequence (default: print the entire sequence) (default: %(default)s)|
|`filename`|Name (path) of the file to save the cyclic pattern to (default: %(default)s)|
|`count`|Number of characters to print from the sequence (default: print the entire sequence)|
|`filename`|Name (path) of the file to save the cyclic pattern to|
## Optional Arguments
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-a`|`--alphabet`|`abcdefghijklmnopqrstuvwxyz`|The alphabet to use in the cyclic pattern (default: %(default)s)|
|`-a`|`--alphabet`|`abcdefghijklmnopqrstuvwxyz`|The alphabet to use in the cyclic pattern|
|`-n`|`--length`|`None`|Size of the unique subsequences (defaults to the pointer size for the current arch)|
|`-o`|`--lookup`|`None`|Do a lookup instead of printing the sequence (accepts constant values as well as expressions)|

@ -20,7 +20,7 @@ usage: down [-h] [n]
|Positional Argument|Help|
| :--- | :--- |
|`n`|The number of stack frames to go down. (default: %(default)s)|
|`n`|The number of stack frames to go down.|
## Optional Arguments

@ -9,10 +9,9 @@
Dump out information on a type (e.g. ucontext_t).
Dump out information on a type (e.g. ucontext_t).
Optionally overlay that information at an address.
Optionally overlay that information at an address.
## Usage:

@ -21,7 +21,7 @@ usage: dumpargs [-h] [-f]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-f`|`--force`||Force displaying of all arguments. (default: %(default)s)|
|`-f`|`--force`||Force displaying of all arguments.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -28,7 +28,7 @@ usage: patch [-h] [-q] address ins
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-q`|`--quiet`||don't print anything (default: %(default)s)|
|`-q`|`--quiet`||don't print anything|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -154,10 +154,10 @@ usage: plist [-h] [-s SENTINEL] [-i INNER_NAME] [-f FIELD_NAME] [-o OFFSET]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-s`|`--sentinel`|`0`|The address that stands in for an end of list marker in a non-cyclic list (default: %(default)s)|
|`-s`|`--sentinel`|`0`|The address that stands in for an end of list marker in a non-cyclic list|
|`-i`|`--inner`|`None`|The name of the inner nested structure where the next pointer is stored|
|`-f`|`--field`|`None`|The name of the field to be displayed, if only one is desired|
|`-o`|`--offset`|`0`|The offset of the first list element to display. Defaults to zero. (default: %(default)s)|
|`-o`|`--offset`|`0`|The offset of the first list element to display. Defaults to zero.|
|`-c`|`--count`|`None`|The number of elements to display. Defaults to the value of dereference-limit.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->

@ -27,8 +27,8 @@ usage: sigreturn [-h] [-a] [-p] [address]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-a`|`--all`||Show all values in the frame in addition to common registers (default: %(default)s)|
|`-p`|`--print`||Show addresses of frame values (default: %(default)s)|
|`-a`|`--all`||Show all values in the frame in addition to common registers|
|`-p`|`--print`||Show addresses of frame values|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -21,7 +21,7 @@ usage: spray [-h] [--value VALUE] [-x] addr [length]
|Positional Argument|Help|
| :--- | :--- |
|`addr`|Address to spray|
|`length`|Length of byte sequence, when unspecified sprays until the end of vmmap which address belongs to (default: %(default)s)|
|`length`|Length of byte sequence, when unspecified sprays until the end of vmmap which address belongs to|
## Optional Arguments
@ -29,7 +29,7 @@ usage: spray [-h] [--value VALUE] [-x] addr [length]
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
||`--value`|`None`|Value to spray memory with, when prefixed with '0x' treated as hex string encoded big-endian|
|`-x`|`--only-funcptrs`||Spray only addresses whose values points to executable pages (default: %(default)s)|
|`-x`|`--only-funcptrs`||Spray only addresses whose values points to executable pages|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -21,7 +21,7 @@ usage: tips [-h] [-a]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-a`|`--all`||Show all tips. (default: %(default)s)|
|`-a`|`--all`||Show all tips.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -20,7 +20,7 @@ usage: up [-h] [n]
|Positional Argument|Help|
| :--- | :--- |
|`n`|The number of stack frames to go up. (default: %(default)s)|
|`n`|The number of stack frames to go up.|
## Optional Arguments

@ -21,7 +21,7 @@ usage: valist [-h] addr [count]
|Positional Argument|Help|
| :--- | :--- |
|`addr`|Address of the va_list|
|`count`|Number of arguments to dump (default: %(default)s)|
|`count`|Number of arguments to dump|
## Optional Arguments

@ -33,7 +33,7 @@ usage: killthreads [-h] [-a] [thread_ids ...]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-a`|`--all`||Kill all threads except the current one. (default: %(default)s)|
|`-a`|`--all`||Kill all threads except the current one.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -21,8 +21,8 @@ usage: bugreport [-h] [--run-browser | --use-gh]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-b`|`--run-browser`||Open browser on github/issues/new (default: %(default)s)|
|`-g`|`--use-gh`||Create issue using Github CLI (default: %(default)s)|
|`-b`|`--run-browser`||Open browser on github/issues/new|
|`-g`|`--use-gh`||Create issue using Github CLI|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -21,7 +21,7 @@ usage: configfile [-h] [--show-all]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
||`--show-all`||Display all configuration options. (default: %(default)s)|
||`--show-all`||Display all configuration options.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -13,8 +13,7 @@ Prints out a list of all pwndbg commands.
```bash
usage: pwndbg [-h] [--shell | --all] [-c CATEGORY_ | --list-categories]
[filter_pattern]
usage: pwndbg [-h] [-c CATEGORY_ | --list-categories] [filter_pattern]
```
## Positional Arguments
@ -28,10 +27,8 @@ usage: pwndbg [-h] [--shell | --all] [-c CATEGORY_ | --list-categories]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
||`--shell`||Only display shell commands (default: %(default)s)|
||`--all`||Only display shell commands (default: %(default)s)|
|`-c`|`--category`|`None`|Filter commands by category|
||`--list-categories`||List command categories (default: %(default)s)|
||`--list-categories`||List command categories|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -21,7 +21,7 @@ usage: themefile [-h] [--show-all]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
||`--show-all`||Force displaying of all theme options. (default: %(default)s)|
||`--show-all`||Force displaying of all theme options.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -21,7 +21,7 @@ usage: canary [-h] [-a]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-a`|`--all`||Print out stack canaries for all threads instead of the current thread only. (default: %(default)s)|
|`-a`|`--all`||Print out stack canaries for all threads instead of the current thread only.|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -20,16 +20,16 @@ usage: stack [-h] [-f] [-i] [count] [offset]
|Positional Argument|Help|
| :--- | :--- |
|`count`|number of element to dump (default: %(default)s)|
|`offset`|Element offset from $sp (support negative offset) (default: %(default)s)|
|`count`|number of element to dump|
|`offset`|Element offset from $sp (support negative offset)|
## Optional Arguments
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
|`-f`|`--frame`||Show the stack frame, from rsp to rbp (default: %(default)s)|
|`-i`|`--inverse`||Show reverse stack growth (default: %(default)s)|
|`-f`|`--frame`||Show the stack frame, from rsp to rbp|
|`-i`|`--inverse`||Show reverse stack growth|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -20,8 +20,8 @@ usage: stackf [-h] [count] [offset]
|Positional Argument|Help|
| :--- | :--- |
|`count`|number of element to dump (default: %(default)s)|
|`offset`|Element offset from $sp (support negative offset) (default: %(default)s)|
|`count`|number of element to dump|
|`offset`|Element offset from $sp (support negative offset)|
## Optional Arguments

@ -46,11 +46,11 @@ usage: attachp [-h] [--no-truncate] [--retry] [--user USER] [-e] [-a] [target]
|Short|Long|Default|Help|
| :--- | :--- | :--- | :--- |
|`-h`|`--help`||show this help message and exit|
||`--no-truncate`||dont truncate command args (default: %(default)s)|
||`--retry`||retry until a target is found (default: %(default)s)|
||`--no-truncate`||dont truncate command args|
||`--retry`||retry until a target is found|
||`--user`|`None`|username or uid to filter by|
|`-e`|`--exact`||get the pid only for an exact command name match (default: %(default)s)|
|`-a`|`--all`||get pids also for partial cmdline matches etc (default: %(default)s)|
|`-e`|`--exact`||get the pid only for an exact command name match|
|`-a`|`--all`||get pids also for partial cmdline matches etc|
<!-- END OF AUTOGENERATED PART. Do not modify this line or the line below, they mark the end of the auto-generated part of the file. If you want to extend the documentation in a way which cannot easily be done by adding to the command help description, write below the following line. -->
<!-- ------------\>8---- ----\>8---- ----\>8------------ -->

@ -20,7 +20,7 @@ usage: bc [-h] [which]
|Positional Argument|Help|
| :--- | :--- |
|`which`|Index of the breakpoint to clear. (default: %(default)s)|
|`which`|Index of the breakpoint to clear.|
## Optional Arguments

@ -20,7 +20,7 @@ usage: bd [-h] [which]
|Positional Argument|Help|
| :--- | :--- |
|`which`|Index of the breakpoint to disable. (default: %(default)s)|
|`which`|Index of the breakpoint to disable.|
## Optional Arguments

@ -20,7 +20,7 @@ usage: be [-h] [which]
|Positional Argument|Help|
| :--- | :--- |
|`which`|Index of the breakpoint to enable. (default: %(default)s)|
|`which`|Index of the breakpoint to enable.|
## Optional Arguments

@ -21,7 +21,7 @@ usage: da [-h] address [max]
|Positional Argument|Help|
| :--- | :--- |
|`address`|Address to dump|
|`max`|Maximum string length (default: %(default)s)|
|`max`|Maximum string length|
## Optional Arguments

@ -21,7 +21,7 @@ usage: db [-h] address [count]
|Positional Argument|Help|
| :--- | :--- |
|`address`|The address to dump from.|
|`count`|The number of bytes to dump. (default: %(default)s)|
|`count`|The number of bytes to dump.|
## Optional Arguments

@ -21,7 +21,7 @@ usage: dc [-h] address [count]
|Positional Argument|Help|
| :--- | :--- |
|`address`|The address to dump from.|
|`count`|The number of bytes to hexdump. (default: %(default)s)|
|`count`|The number of bytes to hexdump.|
## Optional Arguments

@ -21,7 +21,7 @@ usage: dd [-h] address [count]
|Positional Argument|Help|
| :--- | :--- |
|`address`|The address to dump from.|
|`count`|The number of dwords to dump. (default: %(default)s)|
|`count`|The number of dwords to dump.|
## Optional Arguments

@ -21,7 +21,7 @@ usage: dq [-h] address [count]
|Positional Argument|Help|
| :--- | :--- |
|`address`|The address to dump from.|
|`count`|The number of qwords to dump. (default: %(default)s)|
|`count`|The number of qwords to dump.|
## Optional Arguments

@ -21,7 +21,7 @@ usage: ds [-h] address [max]
|Positional Argument|Help|
| :--- | :--- |
|`address`|Address to dump|
|`max`|Maximum string length (default: %(default)s)|
|`max`|Maximum string length|
## Optional Arguments

@ -21,7 +21,7 @@ usage: dw [-h] address [count]
|Positional Argument|Help|
| :--- | :--- |
|`address`|The address to dump from.|
|`count`|The number of words to dump. (default: %(default)s)|
|`count`|The number of words to dump.|
## Optional Arguments

@ -34,7 +34,7 @@ log = logging.getLogger(__name__)
T = TypeVar("T")
P = ParamSpec("P")
commands: List[Command] = []
commands: List[CommandObj] = []
command_names: Set[str] = set()
@ -72,8 +72,20 @@ if pwndbg.dbg.is_gdblib_available():
pwndbg_is_reloading = getattr(gdb, "pwndbg_is_reloading", False)
class Command:
"""Generic command wrapper"""
class InvalidDebuggerError(Exception):
"""
Raised when a command is called in a debugger for which
it is disallowed.
"""
pass
class CommandObj:
"""
Represents a command that can be invoked from the
debugger.
"""
builtin_override_whitelist: Set[str] = {
"up",
@ -89,57 +101,111 @@ class Command:
def __init__(
self,
function: Callable[..., str | None],
prefix: bool = False,
command_name: str | None = None,
shell: bool = False,
is_alias: bool = False,
aliases: List[str] = [],
category: CommandCategory = CommandCategory.MISC,
doc: str | None = None,
parser: argparse.ArgumentParser,
command_name: str | None,
category: CommandCategory,
aliases: List[str],
/, # All parameters must be passed in positionally
) -> None:
self.is_alias = is_alias
self.aliases = aliases
assert function
self.function = function
self.command_name = command_name
if self.command_name is None:
# Take the command name from the name of the function
# which defines it, but replace '_' with '-'.
self.command_name = function.__name__.replace("_", "-")
assert "_" not in self.command_name and "Use '-' instead of '_' in command names."
assert self.command_name not in command_names and "Command already exists."
assert (
not (
self.command_name in GDB_BUILTIN_COMMANDS
and self.command_name not in CommandObj.builtin_override_whitelist
and not pwndbg_is_reloading
)
and "Cannot override non-whitelisted built-in command."
)
assert category
self.category = category
self.shell = shell
self.doc = doc
if command_name is None:
command_name = function.__name__
self.aliases = aliases
assert parser
self.parser = parser
# Sets self.help_str and self.description (among other stuff).
self.initialize_parser()
# Let the debugger and pwndbg global state know about it.
self.register_command()
# For commands like hexdump where you get new output from
# continuous invocations.
self.repeat = False
def register_command(self):
"""
Register this object command with the underlying debugger
and update pwndbg global state to know about this command.
"""
def _handler(_debugger, arguments, is_interactive):
self.invoke(arguments, is_interactive)
self.handle = pwndbg.dbg.add_command(command_name, _handler, doc)
self.function = function
# Keep a handle to the command and its aliases so we can
# easily remove them if necessary (not supported with GDB).
self.handles = []
if command_name in command_names:
raise Exception(f"Cannot add command {command_name}: already exists.")
if (
command_name in GDB_BUILTIN_COMMANDS
and command_name not in self.builtin_override_whitelist
and not pwndbg_is_reloading
):
raise Exception(f'Cannot override non-whitelisted built-in command "{command_name}"')
# Tell the debugger about the command...
self.handles.append(pwndbg.dbg.add_command(self.command_name, _handler, self.help_str))
# ...and all of its aliases.
for alias in self.aliases:
self.handles.append(pwndbg.dbg.add_command(alias, _handler, self.help_str))
command_names.add(command_name)
command_names.add(self.command_name)
commands.append(self)
functools.update_wrapper(self, function)
self.__name__ = command_name
def initialize_parser(self):
# Set parser.prog so the help is generated properly.
self.parser.prog = self.command_name
self.repeat = False
# We want to run all integer and otherwise-unspecified arguments
# through fix() so that GDB parses it.
# FIXME: this is weird
for action in self.parser._actions:
if isinstance(action, argparse._SubParsersAction):
action.type = str
if action.dest == "help":
continue
if action.type is int:
action.type = fix_int_reraise_arg
elif action.type is None:
action.type = fix_reraise_arg
def split_args(self, argument: str) -> Tuple[List[str], Dict[Any, Any]]:
"""Split a command-line string from the user into arguments.
class GoodFormatter(
argparse.RawDescriptionHelpFormatter, argparse.ArgumentDefaultsHelpFormatter
):
pass
This is only used by pwndbg/commands/shell.py which is deprecated.
Usually _ArgparsedCommand.split_args is called.
assert (
self.parser.formatter_class is argparse.HelpFormatter
and "All pwndbg commands should use the same formatter."
)
Returns:
A ``(tuple, dict)``, in the form of ``*args, **kwargs``.
The contents of the tuple/dict are undefined.
"""
return pwndbg.dbg.lex_args(argument), {}
# FIXME: The defaults are not currently reflected in the docs.
self.parser.formatter_class = GoodFormatter
# Generate command help (after we have selected the formatter)
self.help_str = self.parser.format_help()
# Used by `pwndbg [filter]`
assert (
self.parser.description
and self.parser.description.strip()
and "A command must contain a description."
)
self.description = self.parser.description.strip()
def invoke(self, argument: str, from_tty: bool) -> None:
"""Invoke the command with an argument string"""
@ -147,24 +213,32 @@ class Command:
log.error("Pwndbg commands require a target binary to be selected")
return
# Put the arguments through the debugger
try:
args, kwargs = self.split_args(argument)
except SystemExit:
# Raised when the usage is printed by an ArgparsedCommand
# because of an error in argument parsing
return
arg_list = pwndbg.dbg.lex_args(argument)
except (TypeError, pwndbg.dbg_mod.Error):
pwndbg.exception.handle(self.function.__name__)
return
# Put the arguments through argparse
try:
kwargs = vars(self.parser.parse_args(arg_list))
except SystemExit:
# argparse complained about incorrect usage or printed
# help and exited. Either way the appropriate message
# is already printed and we shouldn't call the function.
return
try:
self.repeat = self.check_repeated(argument, from_tty)
self(*args, **kwargs)
# Call this object, same as `self(**kwargs)` but faster.
self.__call__(**kwargs)
finally:
self.repeat = False
def check_repeated(self, argument: str, from_tty: bool) -> bool:
"""Keep a record of all commands which come from the TTY.
"""
Keep a record of all commands which come from the TTY.
Returns:
True if this command was executed by the user just hitting "enter".
@ -181,8 +255,8 @@ class Command:
number, command = last_line[-1]
# A new command was entered by the user
if number not in Command.history:
Command.history[number] = command
if number not in CommandObj.history:
CommandObj.history[number] = command
return False
# Somehow the command is different than we got before?
@ -195,13 +269,81 @@ class Command:
try:
return self.function(*args, **kwargs)
except TypeError:
print(f"{self.function.__name__.strip()!r}: {inspect.getdoc(self.function).strip()}")
print(f"{self.command_name}: {self.description}")
pwndbg.exception.handle(self.function.__name__)
except Exception:
pwndbg.exception.handle(self.function.__name__)
return None
class Command:
"""
Parametrized decorator for functions that serve as pwndbg commands.
Always use this to decorate your commands.
"""
def __init__(
self,
parser_or_desc: argparse.ArgumentParser | str,
*, # All further parameters are not positional
category: CommandCategory,
command_name: str | None = None,
aliases: List[str] = [],
only_debuggers: Set[pwndbg.dbg_mod.DebuggerType] = None,
exclude_debuggers: Set[pwndbg.dbg_mod.DebuggerType] = None,
) -> None:
# Setup an ArgumentParser even if we were only passed a description.
if isinstance(parser_or_desc, str):
self.parser = argparse.ArgumentParser(description=parser_or_desc)
else:
assert isinstance(parser_or_desc, argparse.ArgumentParser)
self.parser = parser_or_desc
self.category = category
self.command_name = command_name
self.aliases = aliases
self.only_debuggers = only_debuggers
self.exclude_debuggers = exclude_debuggers
def __call__(self, function: Callable[..., Any]) -> CommandObj:
# Since this is the __call__ of a parametrized decorator, it is
# invoked during decoration, and it must return a callable object
# i.e. the "real" decorator of the function.
# If this command is not valid for this debugger, do not even
# pass it to ComandObj to be registered with the debugger API.
# Also make sure it raises an error if it is called from the code.
if self.only_debuggers is not None and pwndbg.dbg.name() not in self.only_debuggers:
def decorator(*args, **kwargs):
raise InvalidDebuggerError(
f"This command cannot be used in {pwndbg.dbg.name()}.\n"
f"It is only valid for {self.only_debuggers}."
)
return decorator # type: ignore[return-value]
if self.exclude_debuggers is not None and pwndbg.dbg.name() in self.exclude_debuggers:
def decorator(*args, **kwargs):
raise InvalidDebuggerError(
f"This command cannot be used in {pwndbg.dbg.name()}.\n"
f"It is invalid for {self.exclude_debuggers}."
)
return decorator # type: ignore[return-value]
# Since CommandObj has __call__ defined, an instance of it is a
# callable object (which essentially decorates the function).
return CommandObj(
function,
self.parser,
self.command_name,
self.category,
self.aliases,
)
def fix(
arg: pwndbg.dbg_mod.Value | str, sloppy: bool = False, quiet: bool = True, reraise: bool = False
) -> str | pwndbg.dbg_mod.Value | None:
@ -557,104 +699,6 @@ def OnlyWithResolvedHeapSyms(function: Callable[P, T]) -> Callable[P, T | None]:
return _OnlyWithResolvedHeapSyms
class _ArgparsedCommand(Command):
def __init__(
self,
parser: argparse.ArgumentParser,
function,
command_name=None,
*a,
**kw,
) -> None:
self.parser = parser
if command_name is None:
# Take the command name from the name of the function
# which defines it, but replace '_' with '-'.
self.parser.prog = function.__name__.replace("_", "-")
else:
self.parser.prog = command_name
file = io.StringIO()
self.parser.print_help(file)
file.seek(0)
doc = file.read()
# Note: function.__doc__ is used in the `pwndbg [filter]` command display
function.__doc__ = self.parser.description.strip()
# Type error likely due to https://github.com/python/mypy/issues/6799
super().__init__( # type: ignore[misc]
function,
command_name=self.parser.prog,
doc=doc,
*a,
**kw,
)
def split_args(self, argument: str):
argv = pwndbg.dbg.lex_args(argument)
return (), vars(self.parser.parse_args(argv))
class ArgparsedCommand:
"""Adds documentation and offloads parsing for a Command via argparse"""
def __init__(
self,
parser_or_desc: argparse.ArgumentParser | str,
category: CommandCategory,
command_name: str | None = None,
aliases: List[str] = [],
only_debuggers: Set[pwndbg.dbg_mod.DebuggerType] = None,
exclude_debuggers: Set[pwndbg.dbg_mod.DebuggerType] = None,
) -> None:
"""
:param parser_or_desc: `argparse.ArgumentParser` instance or `str`
"""
if isinstance(parser_or_desc, str):
self.parser = argparse.ArgumentParser(description=parser_or_desc)
else:
assert isinstance(parser_or_desc, argparse.ArgumentParser)
self.parser = parser_or_desc
self.aliases = aliases
assert command_name is None or "_" not in command_name
self._command_name = command_name
assert category
self.category = category
self.only_debuggers = only_debuggers
self.exclude_debuggers = exclude_debuggers
# We want to run all integer and otherwise-unspecified arguments
# through fix() so that GDB parses it.
for action in self.parser._actions:
if isinstance(action, argparse._SubParsersAction):
action.type = str
if action.dest == "help":
continue
if action.type is int:
action.type = fix_int_reraise_arg
if action.type is None:
action.type = fix_reraise_arg
if action.default is not None:
action.help += " (default: %(default)s)"
def __call__(self, function: Callable[..., Any]) -> _ArgparsedCommand:
if self.only_debuggers is not None and pwndbg.dbg.name() not in self.only_debuggers:
return function # type: ignore[return-value]
if self.exclude_debuggers is not None and pwndbg.dbg.name() in self.exclude_debuggers:
return function # type: ignore[return-value]
for alias in self.aliases:
_ArgparsedCommand(
self.parser, function, command_name=alias, is_alias=True, category=self.category
)
return _ArgparsedCommand(
self.parser,
function,
command_name=self._command_name,
aliases=self.aliases,
category=self.category,
)
def sloppy_gdb_parse(s: str) -> int | str:
"""
This function should be used as ``argparse.ArgumentParser`` .add_argument method's `type` helper.
@ -725,7 +769,6 @@ def load_commands() -> None:
import pwndbg.commands.reload
import pwndbg.commands.ropper
import pwndbg.commands.segments
import pwndbg.commands.shell
import pwndbg.commands.argv
import pwndbg.commands.aslr

@ -467,7 +467,7 @@ parser.add_argument(
# @pwndbg.commands.OnlyWhenRunning
@pwndbg.commands.ArgparsedCommand(parser, command_name="ai", category=CommandCategory.INTEGRATIONS)
@pwndbg.commands.Command(parser, command_name="ai", category=CommandCategory.INTEGRATIONS)
def ai(question, model, temperature, max_tokens, verbose, list_models=False, command=None) -> None:
# print the arguments
global last_question, last_answer, last_pc, last_command, verbosity

@ -10,9 +10,7 @@ import pwndbg.commands.telescope
from pwndbg.commands import CommandCategory
@pwndbg.commands.ArgparsedCommand(
"Prints out the number of arguments.", category=CommandCategory.LINUX
)
@pwndbg.commands.Command("Prints out the number of arguments.", category=CommandCategory.LINUX)
@pwndbg.commands.OnlyWhenRunning
def argc() -> None:
print(pwndbg.aglib.argv.argc())
@ -24,7 +22,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.LINUX)
@pwndbg.commands.Command(parser, category=CommandCategory.LINUX)
@pwndbg.commands.OnlyWhenRunning
def argv(i: int = None) -> None:
if i is not None:
@ -47,9 +45,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(
parser, aliases=["env", "environ"], category=CommandCategory.LINUX
)
@pwndbg.commands.Command(parser, aliases=["env", "environ"], category=CommandCategory.LINUX)
@pwndbg.commands.OnlyWhenRunning
@pwndbg.commands.OnlyWhenUserspace
def envp(name: str = None):

@ -57,7 +57,6 @@ def check_aslr() -> Tuple[bool | None, str]:
options = {"on": "off", "off": "on"}
parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter,
description="""
Check the current ASLR status, or turn it on/off.
@ -73,7 +72,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.LINUX)
@pwndbg.commands.Command(parser, category=CommandCategory.LINUX)
def aslr(state=None) -> None:
if state:
if pwndbg.dbg.is_gdblib_available():

@ -56,7 +56,7 @@ input_group.add_argument(
input_group.add_argument("-i", "--infile", default=None, type=str, help="Specify input file")
@pwndbg.commands.ArgparsedCommand(parser, command_name="asm", category=CommandCategory.MISC)
@pwndbg.commands.Command(parser, command_name="asm", category=CommandCategory.MISC)
def asm(shellcode, format, arch, avoid, infile) -> None:
if infile:
print(message.warn("Going to read from file: " + infile))

@ -30,7 +30,6 @@ pwndbg.config.add_param(
)
parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter,
description="""Attaches to a given pid, process name, process found with partial argv match or to a device file.
This command wraps the original GDB `attach` command to add the ability
@ -131,7 +130,7 @@ def find_pids(target, user, exact, all):
return pids_exact_match_cmd or pids_partial_match_cmd or pids_partial_match_args
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.START)
@pwndbg.commands.Command(parser, category=CommandCategory.START)
def attachp(target, no_truncate, retry, exact, all, user=None) -> None:
# As a default, the user may want to attach to a binary name taken from currently loaded file name
if target is None:

@ -6,7 +6,7 @@ import pwndbg.commands
from pwndbg.commands import CommandCategory
@pwndbg.commands.ArgparsedCommand(
@pwndbg.commands.Command(
"Print information from the Auxiliary ELF Vector.", category=CommandCategory.LINUX
)
@pwndbg.commands.OnlyWhenRunning
@ -17,7 +17,7 @@ def auxv() -> None:
print(k.ljust(24), v if not isinstance(v, int) else pwndbg.chain.format(v))
@pwndbg.commands.ArgparsedCommand(
@pwndbg.commands.Command(
"Explore and print information from the Auxiliary ELF Vector.", category=CommandCategory.LINUX
)
@pwndbg.commands.OnlyWhenRunning

@ -396,7 +396,7 @@ class BinderVisitor:
parser = argparse.ArgumentParser(description="Show Android Binder information")
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.KERNEL)
@pwndbg.commands.Command(parser, category=CommandCategory.KERNEL)
@pwndbg.commands.OnlyWhenQemuKernel
@pwndbg.commands.OnlyWithKernelDebugSyms
@pwndbg.commands.OnlyWhenPagingEnabled

@ -6,7 +6,7 @@ import pwndbg.integration.binja
from pwndbg.commands import CommandCategory
@pwndbg.commands.ArgparsedCommand(
@pwndbg.commands.Command(
"Synchronize Binary Ninja's cursor with GDB.",
category=CommandCategory.INTEGRATIONS,
command_name="bn-sync",

@ -42,9 +42,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(
parser, command_name="break-if-taken", category=CommandCategory.BREAKPOINT
)
@pwndbg.commands.Command(parser, command_name="break-if-taken", category=CommandCategory.BREAKPOINT)
@pwndbg.commands.OnlyWhenRunning
def break_if_taken(branch) -> None:
install_breakpoint(branch, taken=True)
@ -58,7 +56,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(
@pwndbg.commands.Command(
parser, command_name="break-if-not-taken", category=CommandCategory.BREAKPOINT
)
@pwndbg.commands.OnlyWhenRunning

@ -37,7 +37,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, command_name="canary", category=CommandCategory.STACK)
@pwndbg.commands.Command(parser, command_name="canary", category=CommandCategory.STACK)
@pwndbg.commands.OnlyWhenRunning
def canary(all) -> None:
global_canary, at_random = canary_value()

@ -15,7 +15,7 @@ parser = argparse.ArgumentParser(
parser.add_argument("-f", "--file", type=str, help="Specify the file to run `checksec` on.")
@pwndbg.commands.ArgparsedCommand(parser, command_name="checksec", category=CommandCategory.MISC)
@pwndbg.commands.Command(parser, category=CommandCategory.MISC)
@pwndbg.commands.OnlyWithFile
def checksec(file: str) -> None:
local_path = file or pwndbg.aglib.file.get_proc_exe_file()

@ -16,7 +16,7 @@ parser.add_argument("comment", type=str, default=None, help="The text you want t
file_lists: Dict[str, Dict[str, str]] = {} # This saves all comments.
@pwndbg.commands.ArgparsedCommand(parser, CommandCategory.MISC)
@pwndbg.commands.Command(parser, category=CommandCategory.MISC)
@pwndbg.commands.OnlyWhenRunning
def comm(addr=None, comment=None) -> None:
if addr is None:

@ -111,7 +111,7 @@ def display_config(filter_pattern: str, scope: Scope, has_file_command: bool = T
)
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.PWNDBG)
@pwndbg.commands.Command(parser, category=CommandCategory.PWNDBG)
def config(filter_pattern) -> None:
display_config(filter_pattern, Scope.config)
@ -133,14 +133,14 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.PWNDBG)
@pwndbg.commands.Command(parser, category=CommandCategory.PWNDBG)
def theme(filter_pattern) -> None:
display_config(filter_pattern, Scope.theme)
if pwndbg.dbg.is_gdblib_available():
# Register the configfile command
@pwndbg.commands.ArgparsedCommand(configfile_parser, category=CommandCategory.PWNDBG)
@pwndbg.commands.Command(configfile_parser, category=CommandCategory.PWNDBG)
def configfile(show_all=False) -> None:
configfile_print_scope(Scope.config, show_all)
@ -155,7 +155,7 @@ themefile_parser.add_argument(
if pwndbg.dbg.is_gdblib_available():
# Register the themefile command.
@pwndbg.commands.ArgparsedCommand(themefile_parser, category=CommandCategory.PWNDBG)
@pwndbg.commands.Command(themefile_parser, category=CommandCategory.PWNDBG)
def themefile(show_all=False) -> None:
configfile_print_scope(Scope.theme, show_all)
@ -170,7 +170,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.PWNDBG)
@pwndbg.commands.Command(parser, category=CommandCategory.PWNDBG)
def heap_config(filter_pattern: str) -> None:
display_config(filter_pattern, Scope.heap, has_file_command=False)
print(

@ -316,7 +316,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, aliases=["ctx-out"], category=CommandCategory.CONTEXT)
@pwndbg.commands.Command(parser, aliases=["ctx-out"], category=CommandCategory.CONTEXT)
def contextoutput(section, path, clearing, banner="both", width: int = None):
if not banner: # synonym for splitmind backwards compatibility
banner = "none"
@ -438,7 +438,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, aliases=["ctxp"], category=CommandCategory.CONTEXT)
@pwndbg.commands.Command(parser, aliases=["ctxp"], category=CommandCategory.CONTEXT)
def contextprev(count) -> None:
global selected_history_index
if not context_history:
@ -463,7 +463,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, aliases=["ctxn"], category=CommandCategory.CONTEXT)
@pwndbg.commands.Command(parser, aliases=["ctxn"], category=CommandCategory.CONTEXT)
def contextnext(count) -> None:
global selected_history_index
if not context_history:
@ -495,7 +495,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, aliases=["ctxsearch"], category=CommandCategory.CONTEXT)
@pwndbg.commands.Command(parser, aliases=["ctxsearch"], category=CommandCategory.CONTEXT)
def contextsearch(needle, section) -> None:
if not section:
sections = context_history.keys()
@ -542,7 +542,6 @@ def contextsearch(needle, section) -> None:
expressions = []
parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter,
description="""
Adds an expression to be shown on context.
@ -564,9 +563,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(
parser, aliases=["ctx-watch", "cwatch"], category=CommandCategory.CONTEXT
)
@pwndbg.commands.Command(parser, aliases=["ctx-watch", "cwatch"], category=CommandCategory.CONTEXT)
def contextwatch(expression, cmd) -> None:
expressions.append((expression, cmd))
@ -577,7 +574,7 @@ parser = argparse.ArgumentParser(
parser.add_argument("num", type=int, help="The expression number to be removed from context")
@pwndbg.commands.ArgparsedCommand(
@pwndbg.commands.Command(
parser, aliases=["ctx-unwatch", "cunwatch"], category=CommandCategory.CONTEXT
)
def contextunwatch(num) -> None:
@ -686,7 +683,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, aliases=["ctx"], category=CommandCategory.CONTEXT)
@pwndbg.commands.Command(parser, aliases=["ctx"], category=CommandCategory.CONTEXT)
def context(subcontext=None, enabled=None) -> None:
"""
Print out the current register, instruction, and stack context.
@ -887,7 +884,7 @@ parser = argparse.ArgumentParser(description="Print out all registers and enhanc
parser.add_argument("regs", nargs="*", type=str, default=None, help="Registers to be shown")
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.CONTEXT)
@pwndbg.commands.Command(parser, category=CommandCategory.CONTEXT)
@pwndbg.commands.OnlyWhenRunning
def regs(regs=[]) -> None:
"""Print out all registers and enhance the information."""

@ -16,7 +16,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(
@pwndbg.commands.Command(
parser,
aliases=["xpsr", "pstate"],
category=CommandCategory.REGISTER,

@ -61,7 +61,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, command_name="cyclic", category=CommandCategory.MISC)
@pwndbg.commands.Command(parser, command_name="cyclic", category=CommandCategory.MISC)
def cyclic_cmd(alphabet, length: Optional[int], lookup, count=100, filename="") -> None:
if length is None:
length = pwndbg.aglib.arch.ptrsize

@ -303,7 +303,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.MISC)
@pwndbg.commands.Command(parser, category=CommandCategory.MISC)
def cymbol(add: str, file: str, remove: str, edit: str, load: str, show: str) -> None:
if add:
add_custom_structure(add)

@ -38,7 +38,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.DEV)
@pwndbg.commands.Command(parser, category=CommandCategory.DEV)
@pwndbg.commands.OnlyWhenRunning
def dev_dump_instruction(address=None, force_emulate=False, no_emulate=False) -> None:
if address is not None:
@ -78,7 +78,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.DEV)
@pwndbg.commands.Command(parser, category=CommandCategory.DEV)
def log_level(level: str) -> None:
logging.getLogger().setLevel(getattr(logging, level.upper()))
print(f"Log level set to {level}")

@ -14,7 +14,7 @@ parser.add_argument("a", type=int, help="The first address.")
parser.add_argument("b", nargs="?", default=None, type=int, help="The second address.")
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.MEMORY)
@pwndbg.commands.Command(parser, category=CommandCategory.MEMORY)
def distance(a, b) -> None:
"""Print the distance between the two arguments"""

@ -8,12 +8,10 @@ from pwndbg.color import message
from pwndbg.commands import CommandCategory
parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter,
description="""
Dump out information on a type (e.g. ucontext_t).
Dump out information on a type (e.g. ucontext_t).
Optionally overlay that information at an address.
""",
Optionally overlay that information at an address.""",
)
parser.add_argument(
"typename",
@ -25,7 +23,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.MISC)
@pwndbg.commands.Command(parser, category=CommandCategory.MISC)
def dt(typename: str, address: int | None = None) -> None:
"""
Dump out information on a type (e.g. ucontext_t).

@ -16,7 +16,7 @@ parser = argparse.ArgumentParser(description="Prints determined arguments for ca
parser.add_argument("-f", "--force", action="store_true", help="Force displaying of all arguments.")
@pwndbg.commands.ArgparsedCommand(parser, aliases=["args"], category=CommandCategory.MISC)
@pwndbg.commands.Command(parser, aliases=["args"], category=CommandCategory.MISC)
@pwndbg.commands.OnlyWhenRunning
def dumpargs(force: bool = False) -> None:
args = (not force and call_args()) or all_args()

@ -7,7 +7,7 @@ from pwndbg.color import message
from pwndbg.commands import CommandCategory
@pwndbg.commands.ArgparsedCommand(
@pwndbg.commands.Command(
"Prints the section mappings contained in the ELF header.", category=CommandCategory.LINUX
)
@pwndbg.commands.OnlyWithFile
@ -33,7 +33,7 @@ def elfsections() -> None:
print(f"{start:#x} - {end:#x} ", name)
@pwndbg.commands.ArgparsedCommand(
@pwndbg.commands.Command(
"Prints any symbols found in the .got.plt section if it exists.",
category=CommandCategory.LINUX,
)
@ -42,7 +42,7 @@ def gotplt() -> None:
print_symbols_in_section(".got.plt", "@got.plt")
@pwndbg.commands.ArgparsedCommand(
@pwndbg.commands.Command(
"Prints any symbols found in the .plt section if it exists.", category=CommandCategory.LINUX
)
@pwndbg.commands.OnlyWithFile

@ -1,7 +1,6 @@
from __future__ import annotations
import argparse
from argparse import RawTextHelpFormatter
import pwndbg.commands
from pwndbg.commands import CommandCategory
@ -22,9 +21,7 @@ epilog = """Examples:
(This command supports flags registers that are defined for architectures in the pwndbg/regs.py file)
"""
parser = argparse.ArgumentParser(
description=description, epilog=epilog, formatter_class=RawTextHelpFormatter
)
parser = argparse.ArgumentParser(description=description, epilog=epilog)
parser.add_argument("flag", type=str, help="Flag for which you want to change the value")
parser.add_argument(
"value",
@ -33,7 +30,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, aliases=["flag"], category=CommandCategory.REGISTER)
@pwndbg.commands.Command(parser, aliases=["flag"], category=CommandCategory.REGISTER)
def setflag(flag: str, value: int) -> None:
register_set = pwndbg.aglib.regs.current

@ -10,7 +10,6 @@ import pwndbg.commands
from pwndbg.commands import CommandCategory
parser = argparse.ArgumentParser(
formatter_class=argparse.RawTextHelpFormatter,
description="""Decode X86-64 GDT entries at address
See also:
@ -33,7 +32,7 @@ parser.add_argument(
)
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.MEMORY)
@pwndbg.commands.Command(parser, category=CommandCategory.MEMORY)
@pwndbg.commands.OnlyWhenRunning
@pwndbg.aglib.proc.OnlyWithArch(["x86-64"])
def gdt(address, count) -> None:

@ -18,7 +18,7 @@ parser.add_argument(
@pwndbg.commands.OnlyWithFile
@pwndbg.commands.ArgparsedCommand(parser, category=CommandCategory.INTEGRATIONS)
@pwndbg.commands.Command(parser, category=CommandCategory.INTEGRATIONS)
def ghidra(func) -> None:
try:
print(pwndbg.ghidra.decompile(func))

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save