Skip to main content
Ben Nadel at InVision In Real Life (IRL) 2019 (Phoenix, AZ) with: Wissam Abirached
Ben Nadel at InVision In Real Life (IRL) 2019 (Phoenix, AZ) with: Wissam Abirached

Embedding ZIP Files Inside JPG Files Using ColdFusion (Live Demo)

By
Published in Comments (14)

Earlier this week, I posted a demonstration of how to use ColdFusion to programmatically create zip files and then embed those zip files secretly inside of JPG image files. I also demonstrated how to use ColdFusion to extract this hidden, embedded data from the resultant JPG file. In the comments to the blog post, Gary Fenton asked how to use the resultant file without using ColdFusion. On my machine, Windows XP, it's simply a matter of renaming the file extension. To make sure that we're all on the same page, I put together a quick little demo:

 
 
 
 
 
 
 
 
 
 

I can't say that this works on other versions of Windows, but XP handles it nicely.

Reader Comments

15 Comments

Thanks Ben. I believe you now. :-D I'll run the code locally to generate the merged jpeg. Maybe IE did something to the image when I right-clicked and saved it from your previous blog.

1 Comments

It should be noted that the reason this kinda thing is possible is due to the way some file formats are structured.

JPEG (as well as the various MPEGs, including MP3s) allows junk data to be included with the file - any applications designed to read those files just ignore anything that's not part of a JPEG.

Similarly programs that handle ZIP files will ignore the JPEG portion - what appears to be junk to them.

In Windows you can get away with this sort of thing, just by using file extensions - if it's a .jpg, Windows will try to use your associated image application to read it; but if it's a .zip, it'll use your default compression app.

When it comes to systems that use the actual content to try to identify file types, this may not work so well.

Various Linux frontends (like gnome/KDE) for example will probably identify the first part of the file - an image - and open it using an image editor, even if the extension is .zip (I have yet to test this - probably won't get a chance to touch my Linux boxen in the near future)

Of course, if you choose to open the file using the specific application in question, it shouldn't be a problem.

I'd be interested to see what happens if you use two different file types which can be read by the one application - for example, concatenating a raw WAV file after an mp3 or something, and seeing how winamp/media player handles it (or jpg/png for a smaller test).

-J

15,841 Comments

@Todd,

Looks cool. Anything in particular that I should know about it?

@Paolo,

Thanks for pointing that - that's kind of cool. Maybe today :D

218 Comments

@Ben: It's free? It doesn't nag you like winrar does? :) It's also open-source. I've seen mixed results between 7-Zip files (.7z) and Winrar (.rar), majority of the times 7-Zip won in the compression size. The max compression is still .zip (which 7-Zip still handles). Otherwise, it will un-rar, un-zip, un-7z, etc.

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel