0

我正在关注经典论文Smashing The Stack For Fun And Profit旁边的“Smashing the Stack in 2011”。尽管有关于这些论文的所有 Q/As,但我找不到我的问题的答案。

我正在尝试运行一个简单的 exit(0) 命令,但调用和 jmp 类似于“Smashing The Stack For Fun And Profit”中的 shellcodeasm.c,所以我可以按照论文进行到底(我设法让它工作当我删除呼叫和 jmp 时)。显然,我的以下 shellcodeasm.c 没有打开 shell,但我保留了“为了乐趣和利润而粉碎堆栈”中的名称,因此我的过程更容易遵循。

shellcodeasm.c

void main() {
__asm__("jmp 0xd \n \
        popl   %esi \n \
        movl   $0x1,%eax \n \
        movl   $0x0, %ebx \n \
        int    $0x80 \n \
        call   -0x12 \n \
        .string \"/bin/sh\" ");
}

运行gcc -o shellcodeasm -g -ggdb shellcodeasm.c并使用 gdb 将十六进制从 main+3 获取到 main 的末尾(如论文中所示)我可以生成我的 testc.c

测试c.c

char shellcode[] =
"\xe9\x29\x7c\xfb\xf7\x5e\xb8\x01\x00\x00\x00\xbb\x00"
"\x00\x00\x00\xcd\x80\xe8\xf8\x7b\xfb\xf7\x2f\x62\x69"
"\x6e\x2f\x73\x68\x00\x5d\xc3";

void main() {
  int *ret;

  ret = (int *)&ret + 2;
  (*ret) = (int)shellcode;

}

然后我可以使用“Smashing the Stack in 2011”中的技术编译和运行它

gcc -o testsc testsc.c -fno-stack-protector
execstack -s testsc
./testsc

但不幸的是,我遇到了分段错误(因为这里没有缓冲区溢出,我猜 -fno-stack-protector 不是必需的,但是当我删除它时它也不起作用)。

有谁知道我不理解/缺少什么?

is的输出和uname -aisLinux core 3.2.0-4-686-pae #1 SMP Debian 3.2.73-2+deb7u3 i686 GNU/Linux的输出。我希望我已经提供了所有相关信息。gcc -vgcc version 4.7.2 (Debian 4.7.2-5)

4

0 回答 0