Monday 17 June 2013

Hiding a file or directory within an image - ::: Linux Tricks:::

This is one severely cool trick which allows you to hide any file or directory within a harmless looking image. When you click on such a file, all you see is the image on your default image viewer. The image is not altered in any way. What you don’t see is the file you have hidden within the image…. Here is precisely how to do it.
  • First you will need a harmless looking .png or .jpg image file… Feel free to download your favorite one from google images.
  • Now, the file or directory you wish to hide has to be compressed into a zip archive.
    $ zip -r <compressed.zip> <file1> <dir1>
  • Now, cat the image you downloaded with the compressed file you created above
    $ cat image.png compressed.zip > secret.png
    NOTE: do not change the ordering of the image and the compressed file. The image always has to always come first in the cat command.
  • Now, remove the files and directories you wanted to hide and also the compressed.zip file using the rm command.
Thats it… You now have a file by the name “secret.png” which if you open, will display the harmless looking image file. Nobody suspects that the image is hiding something sinister(unless ofcourse they are intelligent enough to do a ls -l and see the size of the image file)
Now, all you have to do to get back your secret files and directories is
$ unzip secret.png
Don’t worry if you get some weird warnings or errors when you run the command regarding some invalid content in the header. Thats the whole point you see !!! When we catted the image file at the start of the zip file, we inadvertently modified the header of secret.png, and hence the warnings and errors. Nonetheless, you should now see the compressed.zip file in the directory. Just extract its secret contents with
$ unzip compressed.zip

No comments:

Post a Comment