Skip to content

Instantly share code, notes, and snippets.

@NanoDano
Created July 31, 2016 18:24
Show Gist options
  • Save NanoDano/98c927f265ade49161bae737e42388c1 to your computer and use it in GitHub Desktop.
Save NanoDano/98c927f265ade49161bae737e42388c1 to your computer and use it in GitHub Desktop.
Create a stego image/zip archive with Python
# create_stego_zip_jpg.py - Hide a zip file inside a JPEG
import sys
# Start with a jpeg file
jpg_file = open(sys.argv[1], 'rb') # Path to JPEG
jpg_data = jpg_file.read()
jpg_file.close()
# And the zip file to embed in the jpeg
zip_file = open(sys.argv[2], 'rb') # Path to ZIP file
zip_data = zip_file.read()
zip_file.close()
# Combine the files
out_file = open('special_image.jpg', 'wb') # Output file
out_file.write(jpg_data)
out_file.write(zip_data)
out_file.close()
# The resulting output file appears like a normal jpeg but can also be
# unzipped and used as an archive.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment