下载此文档

堆栈溢出调试gdb例子.ppt


文档分类:IT计算机 | 页数:约16页 举报非法文档有奖
1/16
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/16 下载此文档
文档列表 文档介绍
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2011
A Stack Frame
Parameters
Return Address
Calling Stack Pointer
Local Variables
Addresses
SP
SP+offset
SP: stack pointer BP: base/frame pointer
Calling stack pointer: previous function’s SP
BP
2
Using GDB to Check Stack
GDB tutorial:
When compile the c code, use “gcc –g …..” so that Gdb can match source code line number with code
Some knowledge:
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
3
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.
4
Example of Using GDB
#include <>
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()?
5
******@eustis:~/buffer-code$ setarch i686 –R gdb ./gdb-example
(gdb) list
1 #include <>
2 void foo(char * input){
3 int a1=11;
4 int a2=22;
5 char buf[7];
6 strcpy(buf, input);
7 }
8 void main(int argc, char **argv){
9 foo(argv[1]);
10

堆栈溢出调试gdb例子 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数16
  • 收藏数0 收藏
  • 顶次数0
  • 上传人sxlw2016
  • 文件大小126 KB
  • 时间2021-07-11