Skip to content

Instantly share code, notes, and snippets.

@fabiocerqueira
Last active March 2, 2018 11:45
Show Gist options
  • Select an option

  • Save fabiocerqueira/9d28587e22a1cb769234e4993ba6d87c to your computer and use it in GitHub Desktop.

Select an option

Save fabiocerqueira/9d28587e22a1cb769234e4993ba6d87c to your computer and use it in GitHub Desktop.
environment variables
import subprocess
import os
os.environ['MY_SECRET'] = 'oi :D'
ret = subprocess.run(["python3.6", "sub.py"], stdout=subprocess.PIPE)
if 'MY_SECRET' in ret.stdout.decode('utf-8'):
print('pwned!')
import subprocess
import os
os.environ['MY_SECRET'] = 'oi :D'
with subprocess.Popen(['python3.6', 'sub.py'],
stdout=subprocess.PIPE,
env={'PATH': os.environ['PATH']}) as proc:
ret = proc.stdout.read()
if 'MY_SECRET' in ret.decode('utf-8'):
print('pwned!')
else:
print('safe!')
import os
for k, v in os.environ.items():
print(k, v)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment