I don’t know how many of you know this trick. Did you know that you can hide a ZIP file inside a JPG image? It has been 10 or more years that i know this trick but never (hmm maybe not) have shared this with others.
Actually it is not a trick. It is a logical “file format” hack that allows you to add a zip file inside a JPEG image and use both of the formats by just renaming the file. It works 100% on Windows systems, hence these systems tend to identify the file format from the extension.
What we will create is a big image with 4 thumbnailed images that when renamed to main.zip it will include the thumbnail’s original images. For those that just want to see the final file, here it is:
If you download this image (706kb) and rename it, you will be able to open the zip file and find the images included.
Now, if you want to see how this can happen, read on.
What is going on?
Plain simple explanation: The JPEG file format stores data on first bytes of the file and the ZIP file format stores data on the last ones. So you can add any info you want at the last bytes of a JPEG image and any info you want on the first bytes of a ZIP file.
How ?
Lets get 4 or more images, files, icons or any other file you want and zip them. Lets name the zip file as collection.zip . Then all you have to do is grab a JPEG image like this one and open it up with a hex editor.
Create a new file in the hex editor and copy and paste the image data in it:
Do the same for the collection.zip file but paste the data on the bottom of the image data you pasted before. Now save the file from the File menu as landscape1.jpg
As you can see, the image can still be opened and viewed with no problems (except the filesize is bigger now). If you rename the file to landscape.zip, the image turns into a zip file that contains your images.
Credits
This trick originates from +mala back in 2003! If you like to learn more about file formats and other extremelly old but great stuff you can try and earn your passage to +mala’s site.
Popularity: 1%
No related posts.
About the Author:
Filed under: Tutorials - Trackback Uri
17 Comments.
Trackbacks/Pingbacks
-
[...] Excellent Trick on JPG Images. An Image That Contains Images | Jeez Techjeez.eu [...]








even easier in *nix environments: cat file1.zip >> file2.jpg
This will append the contents of a zip to the end of a jpg – end result is the same.
Does the image work as supposed too? Didn’t try this on linux ever
at the command prompt in windows, this works just as well :
copy file01.jpg /b + file02.zip /b result03.jpg /b
/b – is the binary copy flag
It’s easy in Windows, too. No hex editor required.
copy /b image.jpg+collection.zip result.jpg
(I don’t remember if you still need /b on there.)
Didn’t work for me.
Just as easy in Win32: copy file1.zip+file2.jpg file3.jpg
Doh! Only the other way around: copy file1.jpg+file2.zip file3.jpg
JPEG must come first… and you may need a /b before each filename… experiement!
You can also do something to this effect by putting a .jpg and a .rar in the same folder, and than opening up command prompt and type in cd (wherever the file location is) and than typing in copy /b (imaginename).jpg + (rarname).rar (imagename).jpg
So it’d be something like:
cd C:\Users\L\desktop\filelocation
copy /b Veniversum.jpg + Vi.rar Veniversum.jpg
Under windows you should be able to use the copy command to join to files:
copy /b file1.jpg + file2.zip combined.jpg
People have been doing this to embed mp3s of commercial Jpop (funny enough, this is serious business and illegal in Japan) since the late 90’s.
Are the image files compressed when they’re in the zip format? In other words, does the file size change when you change the extension? That would be interesting but I doubt it.
to do this in Windows (or DOS lol) systems use the concatenating copy option -
“copy file1.jpg+file1.zip newjpgzipcombo.jpg”
or to use the appending version that timekiller mentioned (don’t forget to backup the original jpg if you need it) replace “cat” with “type” -
“type file1.zip >> file2.jpg”
In windows at the command line:
copy landscape1.jpg /b + collection.zip /b combined.jpg
Some years ago I used the same trick in Java, attaching a .exe and a .jar, so the .exe was able to run the VM passing itself as classpath and running the Java app. It worked like a charm, creating a self-contained Java application.
Can this trick be used by people writing viruses and trojans?
I think so. But it is a very old known trick that antivirus companies can easily trace and eliminate.