Tip: Hiding Files Inside An Image in Linux
I have a previous post on how to hide files inside an image file in Windows. If you have not read or watched the video yet, it is right here.
Anyway, a comment on that post gave a tip on how to do the same thing on Linux. Of course I tried it and it worked! According to Sebastian of mathemaniac.org, the concept here is really simple. An image file like JPG is read from the beginning of the file and terminated with an ‘End of Image’ marker. An archive file like ZIP has their metadata stored at the end of the file. Put them together and the image will be read as a valid image file and the appended ZIP file will be read as an archive.
Here is how to do it in Linux:
Get an image file and an archive of the files that you want to hide. In this example, I have cat beer_and_cig.jpg and hideme.zip file. The zip file contains an MP3 song that I have stored inside the archive. To create the archive-image file, run this command:
cat beer_and_cig.jpg hideme.zip > ucantseeme.jpg
What this does is the ‘cat‘ command reads the image file first, then reads the zip file and puts them together in the file named ucantseeme.jpg.
To test the integrity of the image file, try this:
# unzip -t ucantseeme.jpg
Archive: ucantseeme.jpg
warning [ucantseeme.jpg]: 4751 extra bytes at beginning or within zipfile
(attempting to process anyway)
testing: Feist - 09 - One Two Three Four.mp3 OK
No errors detected in compressed data of ucantseeme.jpg.
Notice the warning message? The test saw that there were few bytes at the beginning, which means it saw the image file first but the archive is intact and no errors were found.
Perfect!
Related Posts
16 Comments to “Tip: Hiding Files Inside An Image in Linux”
Post comment
Search PinoyTux
Subscribe to Email Feeds
Blog Lounge
Popular Posts
Recent Posts
Drop your Card Here
Recent Comments
- baby
on My October Earnings from Adbrite - ramakanth
on My October Earnings from Adbrite - juan kara-an
on Cebu Pacific Airlines is Evil! - Eugene Engelbrecht
on Cebu Pacific Airlines is Evil! - David Beecher
on Howto: Install yum On RHEL 4









That’s an interesting solution.
Tadas’s last blog post is GTK: Subclassing button
[...] Digg aptikau tokį visai įdomų postą. Na, gal nelabai įdomų Paskaičiau ir pagalvojau, ar nebūtų galima taip persiųsti vykdomųjų [...]
Nice solution. Helped me a lot. Thanks a load.
Dunno if it’s a display issue, but that command should be:
cat filename.zip >> image.jpg
… so it appends the zip instead of replacing it (which the single carat, >, would do).
If you would look closely at the command
cat beer_and_cig.jpg hideme.zip > ucantseeme.jpg
It cat’s two files in a single file so you retain both files and create a new one.
Yea nice one. Pedophiles around the world thank you.
Can I hide my kiddie porn this way? The filz are pretty big…
The pedophiles has nothing to do with this, thank you very much. But now that you mentioned it, they will thank you for giving them an idea.
You realize they made a program to do this in like 2007, its called steghide, its in the ubuntu/debian Repos and its opensource, also they made stegdetect which detects hidden files in images. By the way the process is called Steganography or stego for short, its the art of writing a hidden message in such a way that only someone who knows its there can find it. But your methode is nice also, but with steghide you can encrypt the file and lock the file with a password.
great tip! now i can hide keyloggers in my porn images i randomly send to people!
seriously wat is the legitimate use for this? cating files is useful but I cant think of one non-devious use for this.
“seriously wat is the legitimate use for this? cating files is useful but I cant think of one non-devious use for this.”
In places where free speech does not exist, something like this could be used to send around information while potentially getting around some of the laws.
It works for almost every type of file (I’ve personally been testing image, video and music files). It is not secure, but it is safer than having a file in the open or hidden via normal means.
[...] Puedes encontrar la fuente de la explicación en inglés aquí [...]
With many people, it’s the images they want to hide.
It is good if you have copyright data to send to a frind that you do not wish your ISPs or the gov to see and on Linux you can password zip files.
and you can send odt file and word doc in jpg to make your e-mail private.
H!
Just let you all know you can hide 700MB or more in a JPG
Ok.. that’s fine. Large files just wouldn’t be very hidden. It would be like hiding a fat man under a carpet. It’s only practical to insert relatively small amounts of data into an image (or other file). Otherwise, why not just encrypt the fat man- er.. data.