有没有办法在我的机器上停用缓冲区溢出保护?

Nli*_*tis 12 linux security gcc

我想在我的各种虚拟机上做一些缓冲区溢出的实验,包括(但不限于)Debian 6、Ubuntu 12.04、Fedora 16,但是每次我尝试执行缓冲区溢出漏洞时,我都会收到以下消息:

stack smashing detected (core dumped)
Run Code Online (Sandbox Code Playgroud)

在完成我的研究后,我读到它是在编译器中实现的称为缓冲区溢出保护的功能。GCC例如使用GCC堆栈溢出保护(ProPolice) 锵/ LLVM使用两个缓冲溢出探测器,SafeCode和AddressSanitizer

我的问题是:既然我真的想检查我的机器上的缓冲区溢出攻击有没有办法(编译器标志,也许是一个 linux 配置文件?)来停用缓冲区溢出保护?

Mat*_*teo 16

海湾合作委员会

在 gcc ( man gcc) 上,检查由

  -fstack-protector
      Emit extra code to check for buffer overflows, such as stack smashing attacks.  >This is done by adding a guard variable to functions with
      vulnerable objects.  This includes functions that call alloca, and functions with >buffers larger than 8 bytes.  The guards are initialized when
      a function is entered and then checked when the function exits.  If a guard check >fails, an error message is printed and the program exits.

  -fstack-protector-all
      Like -fstack-protector except that all functions are protected.
Run Code Online (Sandbox Code Playgroud)

您可以通过no-在选项名称前添加来禁用两者

-fno-stack-protector -fno-stack-protector-all
Run Code Online (Sandbox Code Playgroud)

LLVM/Clang

在 LLVM/Clang ( http://clang.llvm.org/docs/UsersManual.html#commandline ) 上启用/禁用 AdressSanitizer:

-f[no-]address-sanitizer:打开内存错误检测器 AddressSanitizer。

和 SAFECode ( http://safecode.cs.illinois.edu/docs/UsersGuide.html )

-f[no-] memsafety

  • 我刚刚用 GCC 4.7 和 4.1 对其进行了测试:无法识别选项 `-fno-stack-protector-all`(`-fstack-protector`、`-fstack-protector-all` 和 `-fno-stack-protector` 是认可) (6认同)
  • 有没有(简单的)方法来检测程序是否已经用 SSP 编译过? (2认同)
  • @Michuelnik 您可以查看二进制文件是否包含对 `__stack_chk_fail` 的任何引用(例如,`strings /bin/mybinary | grep __stack_chk_fail` (2认同)