My ASLR is disabled. Well, I want to get the address of the environment variable "SHELL", so I use the getenv () C function.
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { char* ptr = getenv("SHELL"); printf("%p\n", ptr); }
Address obtained with getenv ()
$ ./getenv 0xbffff752
Address obtained with gdb:
gdb> x/4000s $esp ... (gdb) x/s 0xbffff710 0xbffff710: "SHELL=/bin/bash" (gdb) x/s 0xbffff716 0xbffff716: "/bin/bash"
Why are the addresses different? As already noted, I have to say the correct address in the one received with GDB.
source share