0xRick / 0xRick.github.io

Infosec blog
128 stars 34 forks source link

Protostar Stack0 different behavior #3

Open gianpyc opened 3 years ago

gianpyc commented 3 years ago

Hi, I'm following your blog pages on the buffer overflow and I'm trying to reproduce it on a VM with ubuntu 20.04. In the specific case of stack0 example, I compile it for 32bit architecuture with the command gcc -m32 stack0.c -o stack0 and I get the executable. Then, if I run with the command: python -c "print ('A' * 65 )"| ./stack0

I get: Try again? *** stack smashing detected ***: terminated Aborted (core dumped)

I got the buffer overflow but I should get the print saying the I modified the variable. So, it seems that the variable is not overwritten, where am I wrong?

gianpyc commented 3 years ago

I reply myself... fixed by compiling the source code disabling canaries with -fno-stack-protector option when invoking gcc. So, the resulting command is for instance: gcc -m32 stack0.c -o stack0 -fno-stack-protector