Skip to content

Instantly share code, notes, and snippets.

@quotepilgrim
Created March 29, 2021 05:34
Show Gist options
  • Select an option

  • Save quotepilgrim/8991f41d6cbf5926064e69b3855afed0 to your computer and use it in GitHub Desktop.

Select an option

Save quotepilgrim/8991f41d6cbf5926064e69b3855afed0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import argparse
import base64
import os
import shutil
parser = argparse.ArgumentParser()
parser.add_argument('input', metavar='INPUT',
help='input file')
parser.add_argument('-a', dest='append', action='store_true',
help='append SAUCE to file')
parser.add_argument('-o', dest='output',
help='output file')
args = parser.parse_args()
if os.path.isfile("tmp.bin"):
os.remove("tmp.bin")
if os.path.isfile(args.input):
srcfile = args.input
if args.output:
destfile = args.output
else:
destfile = "endoom.bin"
if srcfile == destfile:
destfile = "tmp.bin"
sauce = "GlNBVUNFMDAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg\
IKAPAAAFKAAAAAAAAAAAAAJJQk0gVkdBAAAAAAAAAAAAAAAAAAAA"
if args.append:
with open(destfile, 'wb') as outfile:
with open(srcfile, 'rb') as infile:
outfile.write(infile.read())
outfile.write(base64.b64decode(sauce))
else:
with open(srcfile, 'rb') as infile:
with open(destfile, 'wb+') as outfile:
shutil.copyfileobj(infile, outfile)
outfile.seek(4000, os.SEEK_SET)
outfile.truncate()
if os.path.isfile('tmp.bin'):
shutil.move('tmp.bin', srcfile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment