Embed a zip file into an image

From LQWiki
Jump to navigation Jump to search
Author: Sag47 (talk, contrib)

This is for intermediate users of computers but I'll slim it down so basic users can benefit from this tutorial as well.


First lets go over some basic terminology.

Encryption is a way to secure your files and scramble your data so that no one can read it but you. If you are interested in using encryption then I suggest TrueCrypt which is free/open source and for Windows, Linux, and MAC.

Steganography is the art and science of writing hidden messages in such a way that no one apart from the sender and intended recipient even realizes there is a hidden message.

So basically steganography is, in a way, more clever and effective at hiding data than encryption because it looks like something else.

An example would be a folder full of family images. One of those images is embedded with a zip file but to a would-be villain it still looks like a folder of images. Only you know which image has the zip file so nothing looks suspicious.

Probably the most effective way of securing/hiding your information is combining Encryption with Stenography. So if my data was truly sensitive that I would require encryption and it needed to be transported then I would put my encrypted file within a zip file and combine it with an image to lower suspicion.

Are you interested yet? Well I'll stop beating around the bush and tell you how to do it! This requires that you have previous knowledge of what an image is and how to zip your files.

How to do it

in Linux

open a console and enter

cat MyImage.png MyZipFile.zip >> output.png

For more information about the cat command type man cat in the terminal. You may zip your files using the zip utility.

zip MyZipFile.zip myfile.txt
zip -r MyZipFile.zip myfolder/

in Mac

Open the terminal from utilities and run the same command as you would in Linux. Google for "man cat" for more information on the cat command.

in Windows

When I say type Ctrl+C it means to hold your Ctrl key down on the keyboard and, with Ctrl still held down, type the C key and then release both keys.

Open your command prompt: Type [Window Key]+R In the run dialog type "cmd" without quotes. And press enter.

Now you must know where your image and zip file are located on your computer. Mine just so happens to be on the desktop and so that is what this command sequence is for. I already have an image called MyImage.png and a zip file called MyZipFile.zip located on my desktop.

C:\Users\User> cd Desktop

C:\Users\User\Desktop> copy /b MyImage.png + MyZipFile.zip output.png
        1 file(s) copied.


If you notice that in "MyImage.png + MyZipFile.zip" the image goes before the zip file and there is a plus (+) symbol in between the two files.

How to open it

Ok, so what use is a zip file if you can't open it because it is an image? Well that problem is solved easily enough.

in Linux and Mac

You just have to rename the image with a .zip extension to be able to unzip it.

mv output.png output.zip
unzip output.zip

in Windows

Open a folder, any folder and click on Tools > Folder Options... (if you are using Windows Vista/7 then you must press the Alt key and then the menu will show up so you can click Tools). Click on the View tab and scroll down and uncheck "Hide extensions for known file types". You can now close that folder and look at your desktop. You will notice that everything has an extension now.

Simply right click on output.png (which is the image/zip file you created in this tutorial) and select rename. Change .png to .zip and now it can be opened as a zip file.

Warnings and Notices

  • NOTE: If you are using Windows XP/2000 then your command line will look a little different but the commands are the same.
  • Once you create this image/zip file then the zip file can't be changed (even if you really want to add more files it won't) so every time you want to add/remove files from your image/zip file then you will have to recreate it from a new image and zip file.
  • DO NOT EDIT your image/zip file with an image editor such as GIMP, Photoshop, or MS Paint. Those programs don't know what a zip file looks like so when you save any changes to the image it will destroy the zip file and only the image will be left behind.
  • Remember that images aren't very big so if you combine a 500MB zip file with an image then the image will be 500MB. To me this would be a suspicious file if I was an attacker so I would look into it. There are better ways of hiding larger files from attackers and steganography is only one of many.

See also