Wednesday, January 12, 2011

Encapsulating (aka Hiding) Files Inside an Image

Also known as steganography.  This is not solely a hacker or terrorist tool.  Sometimes you need to move data around outside of the traditional means.  For instance; you have a blog that doesn't allow you to host files for download, but it lets you display pictures.  :)


The picture below has some Eclipse theme files embedded in it.  There's no plot to overthrow a 3rd world country and it functions as a proper JPEG file unless you right click and open it with your favorite archiving tool.  It's only then that you'll see the compressed files contained within.


If you want to see this in action simply right-click on the image file and save it locally.  Then as previously described; open it with WinZip, 7zip, WinRAR, etc.




So, how do you create this beast?  Simple ... create a compressed file with all the data you want in it.  Drop it into a directory of your choosing.  Add a .JPG file in that directory as well.  Now, open a command prompt in that directory and do a simple copy!


copy /B some.jpg + archive.zip new.jpg

The /B tells it to do a binary copy.  This will not work without it.  You'll end up with "new.jpg" that contains your compressed files.  Easy-peasy!