Curious thing when finding environment variable address in gdb

Viewed 5239

Recently I'm doing some Return-to-libc attack experiment base on the paper Bypassing non-executable-stack during exploitation using return-to-libc with my Ubuntu11.10.

Before my experiment I closed the ALSR.

According to the paper, I can find address of the environment variable SHELL="/bin/bash" in gdb(use gdb to debug the program I want to attack):

enter image description here
enter image description here

But I found that this address is wrong when I try to use it to Return-to-libc experiment.

And then I write a simple program to get the environment variable address:

enter image description here

When I run this program in the Terminal, I get the right address:

enter image description here

With this address I can do the attack.

I also find the related question about this. But the answers doesn't really make sense(the second one may be better).

Just tell me some details about this, please.

1 Answers
Related