How to turn off gcc compiler optimization to enable buffer overflow

后端 未结 6 675
野趣味
野趣味 2020-11-28 01:01

I\'m working on a homework problem that requires disabling compiler optimization protection for it to work. I\'m using gcc 4.4.1 on ubuntu linux, but can\'t figure out which

6条回答
  •  醉酒成梦
    2020-11-28 01:35

    You don't need to disable ASLR in order to do a buffer overflow! Although ASLR is enabled (kernel_randomize_va_space = 2), it will not take effect unless the compiled executable is PIE. So unless you compiled your file with -fPIC -pie flag, ASLR will not take effect.

    I think only disabling the canaries with -fno-stack-protector is enough. If you want to check if ASLR is working or not (Position independent code must be set), use:

    hardening-check executable_name
    

提交回复
热议问题