Skip to content

Instantly share code, notes, and snippets.

@neon12345
Created July 16, 2016 03:04
Show Gist options
  • Save neon12345/7297490c82416e8c5aed662d1d099fb7 to your computer and use it in GitHub Desktop.
Save neon12345/7297490c82416e8c5aed662d1d099fb7 to your computer and use it in GitHub Desktop.
#!/bin/sh
py_script='
import mmap, base64, sys, getopt
def main(argv):
inputfile = ""
needle = b""
try:
opts, args = getopt.getopt(argv,"hi:n:",["ifile=","needle="])
except getopt.GetoptError:
print "catbytes.sh -i <inputfile> -n <needle>"
sys.exit(2)
for opt, arg in opts:
if opt == "-h":
print "catbytes.sh -i <inputfile> -n <needle>"
sys.exit()
elif opt in ("-i", "--ifile"):
inputfile = arg
elif opt in ("-n", "--needle"):
needle = base64.b64decode(arg)
with open(inputfile, "a") as f:
f.write(needle)
if __name__ == "__main__":
main(sys.argv[1:])
'
python -c "$py_script" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment