Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.


I'm reading "The art of exploitation" and would like to try some experiments, including reading from and writing to various memory address. I've created some simple programs and trying to overwrite their variables via various hacks, the problem is that these variables' addresses keep changing every time I run the program, making all this extremely complicated.
I know this is for security reasons but I'm wondering if is it possible to disable it for learning purposes. Here's my system's and gcc's info:

blackbear@blackbear-laptop:~$ uname -a
Linux blackbear-laptop 2.6.32-30-generic #59-Ubuntu SMP Tue Mar 1 21:30:21 UTC 2011 i686 GNU/Linux
blackbear@blackbear-laptop:~$ gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

blackbear@blackbear-laptop:~$ 
share|improve this question

1 Answer 1

up vote 4 down vote accepted

If I'm not mistaken it should be possible to disable the address space randomization via proc filesystem:

echo 0 > /proc/sys/kernel/randomize_va_space

Obviously, you have to be root for this.

share|improve this answer
    
Got it. But it gives me "access denied" even with sudo –  BlackBear Apr 26 '11 at 15:53
1  
That's because shell does the redirection before executing sudo. So if you need/want to use sudo, you have to do it as following: sudo sh -c 'echo 0 > /proc/sys/kernel/randomize_va_space' –  Petr Uzel Apr 26 '11 at 16:04
    
ok, it worked. thank you so much :) –  BlackBear Apr 26 '11 at 16:14
1  
If you're doing this 'by hand' and not in a script, then another option would be using sudoedit. It's quite convenient for setting /proc file values and there's no need to escape the echo command etc. –  Erik P. Apr 26 '11 at 20:26
    
@Erik tee is another common way (see this post) –  Michael Mrozek Apr 26 '11 at 20:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.