I am trying to learn to use buffer overflow attack in Ubuntu. Unfortunately, I cannot turn off Address Space Layout Randomization (ASLR) feature in this OS, which is turned on by default. I have tried some work around found in some fedora books:
echo "0" > /proc/sys/kernel/randomize_va_space
but for some reason the protection's still there. Please give me some suggestions. Thanks.
[edit]Actually the above command was not successful, it said "Permission Denied", even with sudo. How can I fix that?
[adding] I kept on getting segmetation fault error when it shows an address in stack. Is it related to non-executable stack in ubuntu :(?
A buffer overflow attack occurs when a hacker exploits the coding error to perform a malicious activity and compromise the impacted system. The cybercriminal modifies the execution path of the app and overwrites elements of its memory, causing existing files to be damaged or confidential information to be exposed.
Buffer Overflow Solutions The most reliable way to avoid or prevent buffer overflows is to use automatic protection at the language level. Another fix is bounds-checking enforced at run-time, which prevents buffer overrun by automatically checking that data written to a buffer is within acceptable boundaries.
There are mainly four methods to protect against buffer overflows: patch the kernel to prevent stack execution. You can use either: Exec-shield, OpenWall or PaX (included in the Grsecurity and Adamantix patches). fix the source code by using tools to find fragments of it that might introduce this vulnerability.
You will need root perms before attempting it, and if I'm not mistaken, to restart once you've done it.
sudo -i
echo "0" > /proc/sys/kernel/randomize_va_space
found it myself
you have to compile this way:
gcc -fno-stack-protector -z execstack -o OUTPUT INPUT.c
to echo to files with root acces using sudo you can use the following code:
echo "0" | sudo tee /proc/sys/kernel/randomize_va_space
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With