Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable randomization of memory addresses

I'm trying to debug a binary that uses a lot of pointers. Sometimes for seeing output quickly to figure out errors, I print out the address of objects and their corresponding values, however, the object addresses are randomized and this defeats the purpose of this quick check up. Is there a way to disable this temporarily/permanently so that I get the same values every time I run the program.

Oops. OS is Linux fsttcs1 2.6.32-28-generic #55-Ubuntu SMP Mon Jan 10 23:42:43 UTC 2011 x86_64 GNU/Linux

like image 603
0fnt Avatar asked Mar 04 '11 13:03

0fnt


People also ask

How do I turn in ASLR?

Disable ASLR If you just want to test for a single program you can use the setarch command. This leverages a so-called personality flag. The -R option disables the randomization of the virtual address space by turning on ADDR_NO_RANDOMIZE. This option allows programs to disable ASLR and run without any randomization.

How do I turn off ASLR in virtualbox?

randomize_va_space = 0 This will permanently disable ASLR.


2 Answers

On Ubuntu , it can be disabled with...

echo 0 > /proc/sys/kernel/randomize_va_space 

On Windows, this post might be of some help...

http://blog.didierstevens.com/2007/11/20/quickpost-another-funny-vista-trick-with-aslr/

like image 129
Brandon Frohbieter Avatar answered Oct 25 '22 03:10

Brandon Frohbieter


To temporarily disable ASLR for a particular program you can always issue the following (no need for sudo)

setarch `uname -m` -R ./yourProgram 
like image 28
Stephen Avatar answered Oct 25 '22 03:10

Stephen