Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Practicing buffer overflow attack in Ubuntu

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 :(?

like image 398
wakandan Avatar asked Jul 02 '09 02:07

wakandan


People also ask

How do hackers use buffer overflow?

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.

What is the most effective solution to buffer overflow attacks?

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.

How does Linux protect against buffer overflow?

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.


3 Answers

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
like image 83
scragar Avatar answered Sep 25 '22 10:09

scragar


found it myself

you have to compile this way:

gcc -fno-stack-protector -z execstack -o OUTPUT INPUT.c

like image 34
IP-Sh0k Avatar answered Sep 23 '22 10:09

IP-Sh0k


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
like image 43
knittl Avatar answered Sep 25 '22 10:09

knittl