Python - Setting / Getting Environment Variables and Addrs

I need to set an environment variable in Python and find the address in memory where it is located. Since it's on Linux, I don't mind about using libraries that only work consistently on Linux (if that's the only way). How would you do this?

Edit: The scope of the problem is as follows: I'm trying to hack a program for class, and essentially I'm putting my shellcode into an environment variable and then overwriting one byte on the victim code with the address of my environment variable. I need to find a way to automate this in Python, so my question is two-fold:

  • Is there a way to get the address in memory of an environment variable?

  • Can this only be done in bash/C or can I do it purely in Python?


The built in function id() returns a unique id for any object, which just happens to be it's memory address.

For accessing and setting environment variables, read up on the os.environ dictionary. You can also use os.putenv to set an environment variable.

Need Your Help

How to insert multiple rows?

php arrays activerecord yii transactions

I have a set of rows between 10 to 200, which i need to insert into Database. Active Records is slow for this task, i am using command builder by this way: