我现在根据文章 http://www.tenouk.com/Bufferoverflowc/Bufferoverflow4.html。然而我还没有达到目标。每次抛出段错误时都会伴随一些错误信息。
我编译源代码,并想使用 objdump 获取更多信息。转储出来的汇编代码中调用了函数__strcpy_chk,据说“__strcpy_chk()函数不在源标准中;它只在二进制标准中”。
这是编译器用来保护运行时堆栈的机制吗?要完成测试,如何绕过保护?
问候。
I'm now performing a stack buffer overflow attack test on my own PC( Ubuntu 9.10, gcc-4.4.1 ) based on the article http://www.tenouk.com/Bufferoverflowc/Bufferoverflow4.html. Yet I haven't achieved the goal. Each time a segfault is thrown accompanied with some error informaiton.
I compile the source code, and wanna get further information using objdump. Function __strcpy_chk is invoked in the assembly code dumped out, and it's said that "The __strcpy_chk() function is not in the source standard; it is only in the binary standard."
Does this the mechanism a compiler employed to protect runtime stack? To finish my test, how can I bypass the protection?
Regards.
发布评论
评论(1)
该函数试图检查您是否不会意外地把事情搞砸(即覆盖函数的返回地址),并且它是 strcpy 实现的一部分,而不是其规范的一部分。它只是针对
strcpy
问题的部分补丁,但它确实可以保护您免受该网页讨论的问题的影响,而且只需付出很小的代价。如果您想避免这种情况,请编写您自己的
strcpy
版本。您“首先”想到的简单实现应该存在问题,并且可以很好地进行演示。The function is attempting to check that you don't smash things up too badly by accident (i.e., overwriting the return address of the function) and it's part of the implementation of
strcpy
and not its specification. It's only a partial patch for the problems withstrcpy
, but it does protect you a fair bit against the problems that that webpage talks about, and only with a small cost.If you want to avoid it, write your own version of
strcpy
. The naïve implementation you'll “first” think of should have the problem and will do nicely for demonstration.