PDA

View Full Version : [ubuntu] exploiting a buffer overflow



lolzwut
January 26th, 2010, 08:01 AM
Wow, I have to give it up for the Ubuntu developers. It is nearly impossible to exploit a simple stack overflow. I'm studying overflows for a project so I need it to work. I set /proc/sys/kernel/randomize_va_space to 0 and when I compiled my program I used -mpreferred-stack-boundary=2 and -fno-stack-protector. But for some reason no matter how much input I enter it won't overwrite the EIP. What is stopping this from working that other linux versions don't have? And does anyone know of a way to bypass it? Thanks.


PS: I apologize if this is in the wrong section

rookcifer
January 26th, 2010, 06:18 PM
Wow, I have to give it up for the Ubuntu developers. It is nearly impossible to exploit a simple stack overflow. I'm studying overflows for a project so I need it to work. I set /proc/sys/kernel/randomize_va_space to 0 and when I compiled my program I used -mpreferred-stack-boundary=2 and -fno-stack-protector. But for some reason no matter how much input I enter it won't overwrite the EIP. What is stopping this from working that other linux versions don't have? And does anyone know of a way to bypass it? Thanks.


PS: I apologize if this is in the wrong section

If you are using 64 bit Ubuntu, then the NX bit (http://en.wikipedia.org/wiki/NX_bit) is set to be enabled by default. This marks certain memory regions as non-executable (including the stack) by default. You have to disable this bit. You can do this per program or you can turn it off completely.

Try compiling your program with these flags:


gcc -fno-stack-protector -z execstack program.c

The -z execstack marks it as executable.

EDIT: you might have to install the execstack package first. Just apt-get install it.