版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack MemoryCliff ZouSpring 2011,2,A Stack Frame,Parameters Return Address Calling Stack Pointer Local Variables,00000000,Addresses,SP,SP+offset,SP: stack pointer BP: base/frame pointer Calling stack
2、 pointer: previous functions SP,BP,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: /wiki/X86_assembly_language Register eip: instruction pointer, the current position of next e
3、xecutable 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 executions corresponding line number Break linenumber: set breakpoint at the linenumber Run argv: run the execution code wit
4、h 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 Regist
5、er EIP Calling stack pointer is in Register EBP x int a2=22; char buf7; strcpy(buf, input); void main(int argc, char *argv) foo(argv1); Question: What does the stack look like before strcpy()?,5,czoueustis:/buffer-code$ setarch i686 R gdb ./gdb-example (gdb) list 1 #include 2 void foo(char * input)
6、3 int a1=11; 4 int a2=22; 5 char buf7; 6 strcpy(buf, input); 7 8 void main(int argc, char *argv) 9 foo(argv1); 10 (gdb) break 6 Breakpoint 1 at 0 x8048388: file gdb-example.c, line 6. (gdb) run “whatever” Starting program: /home/czou/buffer-code/gdb-example whatever Breakpoint 1, foo (input=0 xbffff
7、92e whatever) at gdb-example.c: 6 strcpy(buf, input);,6,Remove address randomization used in Unix (will talk in next lecture),(gdb) info frame Stack level 0, frame at 0 xbffff750: eip = 0 x8048388 in foo (gdb-example.c:6); saved eip 0 x80483bd called by frame at 0 xbffff760 source language c. Arglis
8、t at 0 xbffff748, args: input=0 xbffff92e whatever Locals at 0 xbffff748, Previous frames sp is 0 xbffff750 Saved registers: ebp at 0 xbffff748, eip at 0 xbffff74c (gdb) x int i, maxlen = 100; int len; if (arglen maxlen) len = strlen(arg); strncpy(buf, arg, len); If input to foo(*arg, Big_Value) whe
9、re Big_Value overflows short, then arglen could be negative value and passes the if() security check.,Explanation of Project 1,14,In the exploit.c code: #define TARGET /home/jobert/cap6135/1/proj1-fa08/targets/target Need to be changed to point to your own target code Change args1 = hi there; args1
10、needs to point to a large buffer that can cause overflow to target code You can define such a large buffer here and make args1 points to it. Your main task is to: Find out the where in stack stores the return address Find out where is the starting point of buf in foo() in target code Fill the shellc
11、ode into the large buffer in your exploit code (which will fill the buf variable in target code) Assign the starting address of buf to the right place in the large buffer in your exploit code in order to overwrite the return address, then CPU will run the shellcode you put at the start of buf variab
12、le.,Several Tips on Project 1,Be sure to use the Makefile to generate executable of both exploit program and target program Be sure to use “setarch i686 -R” in front of every execution, including both Gdb and ./exploit You can use “break foo” to set breakpoint upon entering foo() function. Fill the
13、shell executable code (in the string array shellcode) byte-by-byte into the buffer for your modified return address to execute, do not use strcpy() because shellcode is not an ASCII string.,Several Tips on Project 1,16,Given that: We know the address of buf in target.c is: 0 xbfff0000 We know the address of the functions return address (eip) is 0 xbfff0100 We put the shellcode at the beginning of buf. How to Overwrite the return address to execute shellcode? 0 xbfff0100 0 xbfff0000 = 0 x100 = 256 in decimal
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 粉条粉丝项目可行性研究报告
- 球型改性石墨项目可行性研究报告
- 自闭症儿童心理健康教育案例
- 物流行业发展现状及趋势分析研究
- 市场营销策划方案实例分析
- 人工智能算法在图像处理中的应用
- 生物科技产业发展趋势解读
- 数字政府建设中的信息共享平台构建
- 小学数学教育中游戏化学习资源的开发与应用
- 家政服务在养老院的融合与发展
- 2026年安徽新闻出版职业技术学院单招综合素质考试题库及一套答案详解
- DLT 5035-2016 发电厂供暖通风与空气调节设计规范
- 国际标准行业分类第4版ISICRev-4中文版
- 特种设备安全培训课件
- (2023最新)给水排水管道工程施工及验收规范
- 部编人教版九年级历史下册全册知识点总结
- 新版北师大版小学3三年级数学下册全册教案完整(新教材)
- 矿井水综合利用分析及前景展望
- 室外消防及给水管道
- 云数据中心柴油发电机组施工组织设计方案
- T∕CVMA 76-2021 犬猫氧气疗法技术规范
评论
0/150
提交评论