I am trying simple buffer overflow attacks in linux. I have a vulnerable program which accepts a command line argument. I have another program that sets an environment variable that has some code i want to execute (typically shellcode). Now I am trying to overflow the buffer of my vulnerable program with the address of this environment variable. I have the following questions:
-
When I pass an environment variable as a command line argument, is the content of the variable copied into argv of my vulnerable program?
-
Where in the process’ address space will the environment variables (command line args) be stored? Will it be on the process stack or somewhere else?
You’re presumably doing something like:
If
$SHELLCODEis also an environment variable, the program will get one copy in the environment, preceded bySHELLCODE=so it could be retrieved viagetenv(), and one copy in theargvargument list.