Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

performing simple buffer overflow on Mac os 10.6

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?

like image 345
REALFREE Avatar asked Nov 27 '22 23:11

REALFREE


1 Answers

@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

Source: Turning off buffer overflow protections in GCC.

like image 64
Paolo Moretti Avatar answered Dec 15 '22 10:12

Paolo Moretti