如何关闭Glibc运行时保护? [英] How to turn off Glibc run-time protections?
问题描述
我试图了解代码漏洞,并且测试一些我写的简单程序。但是,Glibc在运行时捕获的许多问题(例如Stack-Smashing,Double Free等)。因此,我想能够运行我的程序没有Glibc的运行时检测错误。有没有办法关闭Glibc的检测? (像编译器标志等)。
I am trying to learn about code vulnerabilities, and am testing some simple programs I wrote. However, many of the issues Glibc catches during runtime (e.g. Stack-Smashing, Double Free, etc.). Thus I would like to be able to run my programs without Glibc's runtime detection errors. Is there a way to turn off Glibc's detection? (like with a compiler flag, etc).
在前面的链接中我看到了如何关闭ASLR和Canaries,但这不是我想要的喜欢做,因为它仍然停止错误像一个Double Free和一些其他堆错误我想尝试(http://stackoverflow.com/questions/2340259/how-to-turn-off-gcc-compiler-optimization-使能缓冲器溢出)。
I saw in a previous link it is described how to turn off ASLR and Canaries, but this is not what I'd like to do, since it still stops errors like a Double Free and some other heap errors I want to try out (http://stackoverflow.com/questions/2340259/how-to-turn-off-gcc-compiler-optimization-to-enable-buffer-overflow).
我也知道你可以使用-w标志关闭编译时警告,但这似乎不是我想要的。我试过阅读GCC标志和查找Glibc的信息,但我还没有到任何地方。因此,我非常感谢任何帮助。感谢。
I also know you can turn off compile-time warnings with the -w flags but that doesn't seem to be what I want either. I've tried reading over the GCC flags and looking up information about Glibc, but I haven't gotten anywhere yet. Thus I would greatly appreciate any help. Thanks.
推荐答案
检查malloc(3)的手册页以了解MALLOC_CHECK_环境变量的用法。使用这个,你可以关闭中止这些双重的自由错误和不能玩的东西。
Check the man page for malloc(3) for usage of the MALLOC_CHECK_ environment variable. Using this, you can turn off 'aborts' for those double free errors and whatnot to play with things.
man malloc
所以如果你的程序被称为'badfree',你可以设置MALLOC_CHECK_命令,或只是设置它每次执行badfree。
So if your program was called 'badfree', you can either set MALLOC_CHECK_ (note trailing underscore) with an export command, or just set it every execution of badfree.
export MALLOC_CHECK_=0
./badfree
- 或 -
MALLOC_CHECK_=0 ./badfree
记住如果你使用第一个方法,对于在shell中运行的任何程序。
Just remember if you use the first method, it's set for ANY program you run in that shell.
malloc(3)手册页中的MALLOC_CHECK_的设置是:
Settings for MALLOC_CHECK_ from the malloc(3) man page are:
MALLOC_CHECK_ =
0 Silently ignore any issues
1 Send error message to stderr
2 abort() is called immediately, killing your program.
3 Do both '1' and '2' (MALLOC_CHECK_ is a bitfield)
这篇关于如何关闭Glibc运行时保护?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!