Created
January 11, 2014 02:26
-
-
Save dangayle/8366221 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
'''Hide a zipfile in an image or unpack an image with a hidden archive in it''' | |
import argparse | |
from zipfile import ZipFile | |
def hide(image_file, archive_file): | |
'''Append an archive onto the end of an image''' | |
# open the image file in "append binary" mode | |
with open(image_file, "ab") as image: | |
# open the archive file in "read only binary" mode | |
with open(archive_file, "rb") as archive: | |
# Append a newline and the contents of the archive onto the image | |
image.write("\n" + archive.read()) | |
def unhide(unhide_file): | |
'''Unpack a zipfile''' | |
zip = ZipFile(unhide_file) | |
zip.extractall() | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-H', '--hide', nargs=2) | |
parser.add_argument('-U', '--unhide') | |
args = parser.parse_args() | |
if args.hide: | |
hide(*args.hide) | |
if args.unhide: | |
unhide(args.unhide) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment