How to turn off gcc compiler optimization to enable buffer overflow

后端 未结 6 661
野趣味
野趣味 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:52

    Urm, all of the answers so far have been wrong with Rook's answer being correct.

    Entering:

    echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
    

    Followed by:

    gcc -fno-stack-protector -z execstack -o bug bug.c
    

    Disables ASLR, SSP/Propolice and Ubuntu's NoneXec (which was placed in 9.10, and fairly simple to work around see the mprotect(2) technique to map pages as executable and jmp) should help a little, however these "security features" are by no means infallible. Without the `-z execstack' flag, pages have non-executable stack markings.

提交回复
热议问题