Another protective countermeasure tries a slightly different approach. Instead of preventing execution on the stack, this countermeasure randomizes the stack memory layout. When the memory layout is randomized, the attacker won't be able to return execution into waiting shellcode, since he won't know where it is.
This countermeasure has been enabled by default in the Linux kernel since 2.6.12, but this book's LiveCD has been configured with it turned off. To turn this protection on again, echo
1 to the /proc filesystem as shown below.
reader@hacking:~/booksrc $ sudo su - root@hacking:~ # echo 1 > /proc/sys/kernel/randomize_va_space root@hacking:~ # exit logout reader@hacking:~/booksrc $ gcc exploit_notesearch.c reader@hacking:~/booksrc ...