I'm trying to learn about stack base overflow and write a simple code to exploit stack. But somehow it doesn't work at all but showing only Abort trap on my machine (mac os leopard)
I guess Mac os treats overflow differently, it won't allow me to overwrite memory through c code. for example,
strcpy(buffer, input) // lets say char buffer[6] but input is 7 bytes
on Linux machine, this code successfully overwrite next stack, but prevented on mac os (Abort trap)
Anyone know how to perform a simple stack-base overflow on mac machine?
@joveha's answer is correct, with GCC you have to compile with the -fno-stack-protector
to turn of the buffer overflow protections.
However, additionally you’ll need to disable the FORTIFY_SOURCE
option, otherwise you’ll get “Abort trap” if you try to do a buffer overflow that uses something like strcpy
or memcpy
.
To disable it, simply compile with the flag -D_FORTIFY_SOURCE=0
, for example:
gcc -g -fno-stack-protector -D_FORTIFY_SOURCE=0 -o overflow overflow.c