Last active
March 2, 2018 11:45
-
-
Save fabiocerqueira/9d28587e22a1cb769234e4993ba6d87c to your computer and use it in GitHub Desktop.
environment variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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!') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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!') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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