pwndbg disassembly and memory
Nearby instructions
Section titled “Nearby instructions”nearpc # pwndbg: around the current instructionnearpc $rip 20 # around an address (supported versions)x/12i $rip # GDB fallbackdisassemble maindisassemble /r main # include instruction bytes| Command | What it does |
|---|---|
nearpc |
pwndbg view of instructions around the current RIP. |
nearpc ADDRESS COUNT |
Shows nearby instructions around an address in versions that support those arguments. |
x/12i $rip |
GDB fallback: prints 12 instructions starting at RIP. |
disassemble main |
Prints the instruction range for main. |
disassemble /r main |
Includes each instruction’s encoded bytes. |
nearpc is a pwndbg convenience command. If its syntax differs in your release, run help nearpc; the GDB x/i and disassemble commands are the portable fallback.
Inspect memory
Section titled “Inspect memory”telescope $rsp 24 # pointer-aware stack viewtelescope $rdi 12 # inspect a pointer argumenthexdump $rdi 64 # pwndbg byte-oriented viewx/64bx $rdi # GDB byte dumpx/s $rdi # string, if NUL-terminatedx/8gx $rsp # eight-byte values| Command | What it does |
|---|---|
telescope ADDRESS COUNT |
Follows pointer-looking values and annotates likely references. |
hexdump ADDRESS LENGTH |
pwndbg byte-oriented view of a memory range. |
x/64bx ADDRESS |
GDB fallback showing 64 individual bytes in hex. |
x/s ADDRESS |
Reads bytes as a NUL-terminated string. |
x/8gx $rsp |
Reads eight 8-byte values from the current stack pointer. |
The requested length is a maximum view, not proof that the memory belongs to the object you expect. Compare the address with the mappings and the program’s input boundaries.
Maps and permissions
Section titled “Maps and permissions”vmmap # pwndbginfo proc mappings # GDBvmmap lists the process’s mapped regions and access permissions. info proc mappings is GDB’s alternative. Use the output to determine which mapping contains an address and whether it is readable, writable, or executable.
Use the mapping to distinguish the main executable, shared libraries, heap, and stack. For PIE, the executable mapping base plus a static offset gives a runtime address only when the offset and mapping are confirmed for that binary.
Find strings and references
Section titled “Find strings and references”search -t string "/bin/sh" # pwndbg; check local help for exact syntaxsearch scans mapped memory for a value; -t string requests string matching in versions that support this flag. help search shows the accepted options in your installed build.
For static work, Ghidra’s string window and cross-references are usually easier to navigate. In the debugger, confirm that the candidate address is mapped and that the bytes match what you expect.