22 Sep 09

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:

main

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:

hex

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.

VN:F [1.8.1_1037]
Rating: 7.5/10 (11 votes cast)
VN:F [1.8.1_1037]
Rating: +1 (from 5 votes)
Excellent Trick on JPG Images. An Image That Contains Images7.51011

Popularity: 2%

  • Share/Bookmark

No related posts.


About the Author:

Filed under: Tutorials - Trackback Uri


17 Comments.

  • timekiller says:

    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.

    UN:F [1.8.1_1037]
    Rating: 3.3/5 (6 votes cast)
    UN:F [1.8.1_1037]
    Rating: +1 (from 3 votes)
  • admin says:

    Does the image work as supposed too? Didn’t try this on linux ever

    UA:F [1.8.1_1037]
    Rating: 2.2/5 (5 votes cast)
    UA:F [1.8.1_1037]
    Rating: -1 (from 5 votes)
  • snotolazz says:

    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

    UN:F [1.8.1_1037]
    Rating: 3.7/5 (3 votes cast)
    UN:F [1.8.1_1037]
    Rating: +2 (from 2 votes)
  • Darren says:

    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.)

    UN:F [1.8.1_1037]
    Rating: 3.7/5 (3 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 2 votes)
  • Rio says:

    Didn’t work for me.

    UN:F [1.8.1_1037]
    Rating: 3.7/5 (3 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 2 votes)
  • Deuce says:

    Just as easy in Win32: copy file1.zip+file2.jpg file3.jpg

    UN:F [1.8.1_1037]
    Rating: 3.7/5 (3 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 2 votes)
  • Deuce says:

    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!

    UN:F [1.8.1_1037]
    Rating: 3.7/5 (3 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 2 votes)
  • L says:

    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

    UN:F [1.8.1_1037]
    Rating: 3.7/5 (3 votes cast)
    UN:F [1.8.1_1037]
    Rating: +1 (from 1 vote)
  • Under windows you should be able to use the copy command to join to files:

    copy /b file1.jpg + file2.zip combined.jpg

    UN:F [1.8.1_1037]
    Rating: 3.7/5 (3 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 2 votes)
  • Jack9 says:

    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.

    UN:F [1.8.1_1037]
    Rating: 3.0/5 (2 votes cast)
    UN:F [1.8.1_1037]
    Rating: -1 (from 1 vote)
  • onemanclic says:

    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.

    UN:F [1.8.1_1037]
    Rating: 3.7/5 (3 votes cast)
    UN:F [1.8.1_1037]
    Rating: -1 (from 1 vote)
  • olli says:

    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”

    UN:F [1.8.1_1037]
    Rating: 3.0/5 (2 votes cast)
    UN:F [1.8.1_1037]
    Rating: -1 (from 1 vote)
  • adam says:

    In windows at the command line:

    copy landscape1.jpg /b + collection.zip /b combined.jpg

    UN:F [1.8.1_1037]
    Rating: 5.0/5 (2 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  • Luciano says:

    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.

    UN:F [1.8.1_1037]
    Rating: 5.0/5 (1 vote cast)
    UN:F [1.8.1_1037]
    Rating: +1 (from 1 vote)
  • Bookster says:

    Can this trick be used by people writing viruses and trojans?

    UN:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.1_1037]
    Rating: 0 (from 0 votes)
  • admin says:

    I think so. But it is a very old known trick that antivirus companies can easily trace and eliminate.

    UA:F [1.8.1_1037]
    Rating: 0.0/5 (0 votes cast)
    UA:F [1.8.1_1037]
    Rating: 0 (from 0 votes)

Trackbacks/Pingbacks