tonybaldwin | blog

non compos mentis

Co0l Linux trick: Hide files in an image

with 7 comments

Here’s a cool trick I just learned.
You can, in a gnu/linux system, hide files within an image file.
Why you might want to do so, of course, is open to speculation, but the “how” is really rather simple.

  1. Choose an image file, any image file. For this example, I will choose a wallpaper I made, say, debianolive.png. Copy this image to a directory with the documents you wish to hide.
  2. Compress the files or documents you wish to hide. This is simple enough. In terminal do:

    :~$ zip file1 file2

  3. Then, in terminal, simply do:

    cat debianolive.png > debianolivehd.png

    (note: target file name is not the same as the original image file name)

All done.

This creates an image with the name “debianolive.png”, which contains our documents.
When we wish to retrieve said documents, we rename the file to

:~$ mv debianolive.png

Then unzip:

:~$ unzip

and you have your files back.

Handy! Nifty!



Written by tonybaldwin

August 11, 2010 at 2:57 pm

7 Responses

Subscribe to comments with RSS.

  1. HAHAHAA+HA. So easy! Tony, that's REALLY awesome. I only wish i lived an exciting life of intrigue in which this trick would be somehow useful to me 🙂 Maybe someday…


    August 12, 2010 at 12:56 am

  2. My nephew made a really nifty perl script for creating individual encryption keys and encrypting messages, but, at the moment, his site seems to be down.
    He and I have passed encrypted messages in said fashion.

    Frankly, I'm pretty sure one could use almost any file type to do this; For instance, hiding files within a music file (.ogg, etc.), .odt file, or even a .txt file, etc., in similar fashion.


    August 12, 2010 at 1:12 am

  3. With this trick, if I open your image with any imagevisor, can I see an image?

    PD: The last three "debianolive.png" was wrote without "hd" 😉


    August 17, 2010 at 3:17 am

    • re: "with any imagevisor, can I see an image?"

      I haven't managed to get that to work. Both gpicview and gthumb gave up.
      Nonetheless, the resultant file "looks" like an image to your file manager, and "ls" in bash shows it as such.
      (file, however, shows it as a zip).
      Most users will simply see an image file in the file manager, and, when an image view fails to open it,
      will simply assume the file is corrupted, or something. They will not see that it is a zip file (unless the do
      file $image in bash), or figure out that there are other files hidden therein.


      August 17, 2010 at 4:44 am

  4. I just did it, it's excelent!
    I'll post it on my blog but in spanish


    August 17, 2010 at 3:21 am

  5. I just reading on security-mailinglist about a troyan -for windows- allowed on PNG file with an embedded .bat file. I'll prove it on gnu if it's possible to run a .sh script


    August 22, 2010 at 4:42 am

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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

%d bloggers like this: