- 13
- 0
- 约5.98千字
- 约 16页
- 2018-10-15 发布于江苏
- 举报
堆栈溢出调试gdb-例子
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack MemoryCliff ZouSpring 2011 * A Stack Frame Parameters Return Address Calling Stack Pointer Local VariablesAddresses SP SP+offset SP: stack pointer BP: base/frame pointer Calling stack pointer: previous function’s SP BP Using GDB to Check Stack GDB tutorial: /library/mac/#documentation/developertools/gdb/gdb/gdb_toc.html /TUTORIALS/GDB-Commands.html#GDB_COMMAND_LINE_ARGS When compile the c code, use “gcc –g …..” so that Gdb can match source code line number with code Some knowledge: /wiki/X86_assembly_language Register eip: instruction pointer, the current position of next executable instruction Register ebp: stack pointer, the top of the current stack, used for addressing local variable * Related Gdb Commands: List: list the source code and each execution’s corresponding line number Break linenumber: set breakpoint at the linenumber Run argv: run the execution code with the parameter argv Next: execute the next line of code Backtrace: show trace of all function calls in stack Info frame: List address, language, address of arguments/local variables and which registers were saved in frame. This will show where the return address is saved Return address is in Register EIP Calling stack pointer is in Register EBP x variable: show the address and value of a local variable (in hex format) x address: print binary representation of 4 bytes of memory pointed to by address. * Example of Using GDB #include stdio.h void foo(char * input){ int a1=11; int a2=22; char buf[7]; strcpy(buf, input); } void main(int argc, char **argv){ foo(argv[1]); } Question: What does the stack look like before strcpy()? * czou@eustis:~/buffer-code$ setarch i686 –R gdb ./gdb-example (gdb) list 1 #include stdio.h 2 void foo(char * input){ 3 int a1=11; 4 int a2=22; 5 char buf[7]; 6
您可能关注的文档
- 基于PLC的产流水线电气控制系统设计毕业答辩PPT.ppt
- 基于PIC单机的TCPIP协议栈实现.ppt
- 基于PBOC.0的多应用实现.ppt
- 基于QTI规的考试系统设计与实现.doc
- 基于Smaat 7多通路声学测量系统的电声系统调试与优.docx
- 基于STM3的uCGUI移植和优化.doc
- 基于VB的间平差程序设计.doc
- 基于Veriog的数模转换器设计.docx
- 基于web3技术的虚拟展厅设计.docx
- 基于web20教师专业发展.ppt
- (正式版)DB51∕T 1867-2014 《袋栽黑木耳生产技术规程》.docx
- (正式版)DB51∕T 2413-2023 《油橄榄密植丰产栽培技术规程》.docx
- (正式版)DB51∕T 2436-2017 《川菜东坡一品肉烹饪工艺技术规范》.docx
- (正式版)DB51∕T 2396-2017 《农村电子商务服务站(点)服务与管理规范》.docx
- (正式版)DB51∕T 2419-2017 《桢楠扦插育苗技术规程》.docx
- CN105145773B 一种无花果曲奇饼干及其制作方法 (江苏农林职业技术学院).docx
- CN105203825A 微测量电极的制作方法和热电势的测量方法及相关装置 (国家纳米科学中心).docx
- CN105137533B 一种啁啾光纤光栅及其制作方法 (南京航空航天大学).docx
- (正式版)DB51∕T 2453-2018 《巴山新居公共管理指南》.docx
- (正式版)DB51∕T 1892-2014 《川西北地区沙化土地治理技术规程》.docx
原创力文档

文档评论(0)