Python - setting / getting environment variables and additions

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

Edit: The problem is this: I'm trying to hack a program for a class, and essentially I put my shellcode in an environment variable and then overwrite one byte per victim code with the address of my environment variable. I need to find a way to automate this in Python, so my question is twofold:

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

  • Can I only do this in bash / C or can I do it exclusively in Python?

+1


source to share


3 answers


The id () built-in function returns a unique identifier for any object, which is simply a memory address.



http://docs.python.org/library/functions.html#id

+1


source


Read the os.environ dictionary to access and set environment variables. You can also use os.putenv to set the environment variable.



+4


source


Pass the address itself in an environment variable and just read it with os.getenv ().

0


source







All Articles