Skip to content

pwndbg disassembly and memory

nearpc # pwndbg: around the current instruction
nearpc $rip 20 # around an address (supported versions)
x/12i $rip # GDB fallback
disassemble main
disassemble /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.

telescope $rsp 24 # pointer-aware stack view
telescope $rdi 12 # inspect a pointer argument
hexdump $rdi 64 # pwndbg byte-oriented view
x/64bx $rdi # GDB byte dump
x/s $rdi # string, if NUL-terminated
x/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.

vmmap # pwndbg
info proc mappings # GDB

vmmap 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.

search -t string "/bin/sh" # pwndbg; check local help for exact syntax

search 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.