pwn常常會用到gdb,看到一篇不錯的文章,記錄了很多命令:https://www.jianshu.com/p/c3e5f5972b21
gdb
基礎調試命令 s step,si步入 n 執行下一條指令 ni步入 b 在某處下斷點,可以用 b * adrress b function_name info b 查看斷點信息 delete 刪除所有斷點 c 繼續 r 執行 disas addr 查看addr處前后的反匯編代碼 disas functions 參看fucntion函數的反匯編代碼
顯示內存數據
p 系列 p system/main 顯示某個函數地址 p $esp 顯示寄存器 p/x p/a p/b p/s。。。 p 0xff - 0xea 計算器 print &VarName 查看變量地址 p * 0xffffebac 查看某個地址處的值 x系列 命令格式:x/<n/f/u> <addr> n是一個正整數,表示需要顯示的內存單元的個數 f 表示顯示的格式(b字符,s字符串,i匯編指令,x十六進制,d十進制) u 表示從當前地址往后請求的字節數 默認4byte,u參數可以用下面的字符來代替,b表示單字節,h表示雙字節,w表示四字 節,g表示八字節 <addr>表示一個內存地址 x/xw addr 顯示某個地址處開始的16進制內容,如果有符號表會加載符號表 x/x $esp 查看esp寄存器中的值 x/s addr 查看addr處的字符串 x/b addr 查看addr處的字符 x/i addr 查看addr處的反匯編結果 info系列 info register $ebp 查看寄存器ebp中的內容 (簡寫為 i r ebp) i r eflags 查看狀態寄存器 i r ss 查看段寄存器 i b 查看斷點信息 i functions 查看所有的函數 disas addr 查看addr處前后的反匯編代碼 stack 20 查看棧內20個值 show args 查看參數 vmmap 查看映射狀況 peda帶有 readelf 查看elf文件中各個段的起始地址 peda帶有 parseheap 顯示堆狀況 peda帶有
查找數據
find 查找字符串 peda帶有 searchmem 查找字符串 peda帶有 ropsearch "xor eax,eax;ret" 0x08048080 0x08050000 查找某段的rop peda帶有 ropgadget 提供多個pop|ret可行結果 peda帶有
pwngdb插件
libc : Print the base address of libc ld : Print the base address of ld codebase : Print the base of code segment heap : Print the base of heap got : Print the Global Offset Table infomation dyn : Print the Dynamic section infomation findcall : Find some function call bcall : Set the breakpoint at some function call tls : Print the thread local storage address at : Attach by process name findsyscall : Find the syscall fmtarg : Calculate the index of format string You need to stop on printf which has vulnerability. force : Calculate the nb in the house of force. heapinfo :打印heap的一些信息 default is the arena of current thread If tcache is enable, it would show infomation of tcache entry heapinfoall : Print some infomation of heap (all threads) arenainfo : Print some infomation of all arena chunkptr : 打印chunk的信息 后面加chunk返回給用戶的地址 printfastbin : 打印fastbin的鏈表信息 tracemalloc on : 追蹤程序chunk的malloc和free parseheap :解析堆的布局 magic : 打印出glibc中一些有用的信息 fp : show FILE structure fp (Address of FILE) fpchain: show linked list of FILE orange : Test house of orange condition in the _IO_flush_lockp orange (Address of FILE) glibc version <= 2.23
pwndbg
top_chunk: 顯示top chunk的信息
malloc_chunk address:打印出已被分配的chunk的信息
fastbins:顯示fastbins鏈表信息
unsorted:顯示unsortedbin 的信息
smallbins:顯示smallbins的信息
largebins:顯示largebins的信息
bins:顯示所有bins的信息
mp:顯示一些內存管理用到的全局變量
arena:顯示分配區的信息