Hide your ASSets the Python way

Some of you may have seen the “trick” of using the command prompt to hide archives in images. Example: “C:>copy /b image1.jpg + stuff.zip newimage.jpg” This will hide stuff.zip in the picture image.jpg and output the merged file as newimage.jpg

As far as I know, this only works with jpeg’s. That’s cool and all, but how does it do that? And how can I do the same with python?

Well, it works by opening each file as it’s binary state and merges the two binaries into one. To view the image, just open it like normal. To view the archive, open it with an archive viewer like 7zip.

Now that we know how it works, lets try and do the same with python.

#open the image a=append, b=open as binary
image = open("test.jpg", "ab")

#open the archive as a binary
archive = open("test.zip","rb")

#write the archive data after a newline
#to our image
image.write("\n"+archive.read())

#close handles
image.close()
archive.close()

As you can see, it only took 5 lines of code. You can view the image as a regular image, or open as a zip file. Alliteratively, you could os.popen() or os.system() with the cmd version as well, but I like to do things the python way.

Short, sweet, and to the point.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.