堆栈溢出调试-gdb-例子

堆栈溢出调试-gdb-例子

ID:22001394

大小:248.00 KB

页数:16页

时间:2018-10-21

堆栈溢出调试-gdb-例子_第1页
堆栈溢出调试-gdb-例子_第2页
堆栈溢出调试-gdb-例子_第3页
堆栈溢出调试-gdb-例子_第4页
堆栈溢出调试-gdb-例子_第5页
资源描述:

《堆栈溢出调试-gdb-例子》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、CAP6135:MalwareandSoftwareVulnerabilityAnalysisBufferOverflow:ExampleofUsingGDBtoCheckStackMemoryCliffZou Spring20112AStackFrameParametersReturnAddressCallingStackPointerLocalVariables00000000AddressesSPSP+offsetSP:stackpointerBP:base/framepointerCallingstackpointer:previousfunction’sSPBPUsin

2、gGDBtoCheckStackGDBtutorial:https://developer.apple.com/library/mac/#documentation/developertools/gdb/gdb/gdb_toc.htmlhttp://www.yolinux.com/TUTORIALS/GDB-Commands.html#GDB_COMMAND_LINE_ARGSWhencompiletheccode,use“gcc–g…..”sothatGdbcanmatchsourcecodelinenumberwithcodeSomeknowledge:http://en.w

3、ikipedia.org/wiki/X86_assembly_languageRegistereip:instructionpointer,thecurrentpositionofnextexecutableinstructionRegisterebp:stackpointer,thetopofthecurrentstack,usedforaddressinglocalvariable3RelatedGdbCommands:List:listthesourcecodeandeachexecution’scorrespondinglinenumberBreaklinenumber:

4、setbreakpointatthelinenumberRunargv:runtheexecutioncodewiththeparameterargvNext:executethenextlineofcodeBacktrace:showtraceofallfunctioncallsinstackInfoframe:Listaddress,language,addressofarguments/localvariablesandwhichregistersweresavedinframe.ThiswillshowwherethereturnaddressissavedReturna

5、ddressisinRegisterEIPCallingstackpointerisinRegisterEBPx&variable:showtheaddressandvalueofalocalvariable(inhexformat)xaddress:printbinaryrepresentationof4bytesofmemorypointedtobyaddress.4ExampleofUsingGDB#includevoidfoo(char*input){inta1=11;inta2=22;charbuf[7];strcpy(buf,input);}void

6、main(intargc,char**argv){foo(argv[1]);}Question:Whatdoesthestacklooklikebeforestrcpy()?5czou@eustis:~/buffer-code$setarchi686–Rgdb./gdb-example(gdb)list1#include2voidfoo(char*input){3inta1=11;4inta2=22;5charbuf[7];6strcpy(buf,input);7}8voidmain(intargc,char**argv){9foo(argv[1]);10}(g

7、db)break6Breakpoint1at0x8048388:filegdb-example.c,line6.(gdb)run“whatever”Startingprogram:/home/czou/buffer-code/gdb-example"whatever"Breakpoint1,foo(input=0xbffff92e"whatever")atgdb-example.c:6strcpy(buf,input);6Removeaddressrandomizationuse

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。