Created
December 22, 2020 06:09
-
-
Save cablehead/0e4ed3f5c669bdcd622448997764bc3f to your computer and use it in GitHub Desktop.
Experimenting with processing http requests with jq + shell2http
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
#!/usr/local/bin/python3 | |
import json | |
import sys | |
import os | |
fh = open("/tmp/out", "a") | |
env = dict(os.environ) | |
skip = ['HOME', 'TMPDIR', 'USER', 'LANG', 'PATH', 'PWD', 'SHLVL', 'SCRIPT_NAME' ] | |
for key in list(env.keys()): | |
if key in skip: | |
del env[key] | |
if key.startswith('_'): | |
del env[key] | |
json.dump({ | |
'env': env, | |
'data': sys.stdin.read(), | |
}, fh) | |
fh.write('\n') | |
fh.close() | |
print("Content-Type: text/plain\n") | |
print("ack.") |
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
shell2http -cgi -host localhost / cgi2json.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment