gdb的调试与使用

2018-07-10  本文已影响283人  cceb9d5a8577

转自:上善若水
这篇应该是我见过的总结最详细的gdb调试指南了,这位博主是个很强的人,他的博客对萌新比较友好,我始终认为那种自己厉害又能把自己所学完美表达出来的人是最强的

1. 调试的快捷键

peda带有的功能,直接输入命令,其就会给予提示(如果不是这样,基本上也是该命令就可以不带参数)。这儿就不多做介绍

1.1 基础的调试快捷键

1.2 显示数据

1.3 查找数据

1.4 修改数据

1.5 peda插件

Enhance the display of gdb: colorize and display disassembly codes, registers, memory information during debugging.
Add commands to support debugging and exploit development (for a full list of commands use peda help):

aslr -- Show/set ASLR setting of GDB

checksec -- Check for various security options of binary

dumpargs -- Display arguments passed to a function when stopped at a call instruction

dumprop -- Dump all ROP gadgets in specific memory range

elfheader -- Get headers information from debugged ELF file

elfsymbol -- Get non-debugging symbol information from an ELF file

lookup -- Search for all addresses/references to addresses which belong to a memory range

patch -- Patch memory start at an address with string/hexstring/int

pattern -- Generate, search, or write a cyclic pattern to memory

procinfo -- Display various info from /proc/pid/

pshow -- Show various PEDA options and other settings

pset -- Set various PEDA options and other settings

readelf -- Get headers information from an ELF file

ropgadget -- Get common ROP gadgets of binary or library

ropsearch -- Search for ROP gadgets in memory

searchmem|find -- Search for a pattern in memory; support regex search

shellcode -- Generate or download common shellcodes.

skeleton -- Generate python exploit code template

vmmap -- Get virtual mapping address ranges of section(s) in debugged process

xormem -- XOR a memory region with a key

Installation

vmmap:查看当前程序映射的内存块
dumprop:

2. 查找某个plt、got、plt_2

3. 查找程序所动态链接的库

4. 编译32位可执行文件

5. 开启PIE之后的调试

开启PIE之后,地址会一直在变,这十分不利于gdb的调试,所以这时候应该在本地关闭ASLR

常用的方法是:echo 0 > /proc/sys/kernel/randomize_va_space

开启的方式是:echo 2 > /proc/sys/kernel/randomize_va_space

6. 运行时查看文件执行

做了一道题,在你不执行的时候,只能找到相对地址,但是下断点需要实际的执行地址。若关闭PIE,那么每次的执行地址将会一致,这个时候就需要找到执行的开始地址。peda的常用指令中有vmmap,可以找到实际地址。

这道题很让人苦恼的是,如果gdb中执行run,那么将陷入循环而不能使用vmmap,若强制结束,最后vmmap会报错。这个时候,就有另外的一些办法:

上一篇 下一篇

猜你喜欢

热点阅读