Created
March 29, 2021 05:34
-
-
Save quotepilgrim/8991f41d6cbf5926064e69b3855afed0 to your computer and use it in GitHub Desktop.
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/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