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

Posted January 22, 2009 at 4:10 PM by Ben Nadel

Tags: ColdFusion

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

Jan 22, 2009 at 7:54 PM // reply »
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.


Jan 22, 2009 at 9:44 PM // reply »
110 Comments

That still seems crazy to me that it works so nicely :) Really cool though.


Jan 22, 2009 at 11:03 PM // reply »
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


Jan 23, 2009 at 1:40 AM // reply »
34 Comments

Ben - Just one more post till your 1000th Cold fusion post :)
hahahahaha!


Jan 23, 2009 at 8:25 AM // reply »
211 Comments

BTW, I was a big WinRAR fan too, but it's time to move to 7-Zip ( http://www.7-zip.org/ ).


Jan 23, 2009 at 9:11 AM // reply »
110 Comments

@Todd
Cool. I didn't know that it handled RAR files also. I'll have to see how much quicker it is that WinRAR.


Jan 23, 2009 at 9:15 AM // reply »
211 Comments

@Gareth: It can only un-rar a .rar file. Can't create.


Jan 23, 2009 at 9:34 AM // reply »
11,241 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


Jan 23, 2009 at 9:38 AM // reply »
211 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.


Jan 23, 2009 at 9:39 AM // reply »
11,241 Comments

@Todd,

Sounds good to me. I do like free :) I'll give it a look-see.


Jan 23, 2009 at 9:41 AM // reply »
211 Comments

And, if you don't like the 7z interface, you could use jZip ( http://www.jzip.com/ ) - which uses the 7z compression engine and basically gives it a better facelift.


Feb 19, 2009 at 1:42 AM // reply »
1 Comments

Thats interesting info.!!


Oct 7, 2009 at 11:56 PM // reply »
1 Comments

If you were to use "Open With..." and select 7zip, you wouldn't even need to change the extension. :)


May 22, 2010 at 1:05 PM // reply »
1 Comments

try http://www.openrarfile.com/open-rar-file

nothing to download, all webbased



Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
May 22, 2013 at 7:52 AM
Nested Views, Routing, And Deep Linking With AngularJS
Hi, Just a quick thank you. As it happens, for my own purposes, the pending ui-router work being done in native angular is likely the one I'll adopt, but your exploration, code and documentation of ... read »
May 22, 2013 at 4:43 AM
How Do You Use The ColdFusion CFParam Tag?
'<cfparam>' or 'isDefined()and <cfset>' performs the same task.Is there any difference? ... read »
May 21, 2013 at 7:46 PM
Using Plupload For Drag & Drop File Uploads In ColdFusion
No luck. At least I have uncovered the cause, URLScan 3.1. Here is what I see in the IIS log when a file is over 30mb. 2013-05-21 23:29:05 10.105.45.128 GET /plupload/assets/jquery/jquery-1.8. ... read »
May 21, 2013 at 6:12 PM
Using Plupload For Drag & Drop File Uploads In ColdFusion
Ben, I did not see you after Pete Freitag's Lockdown session at cfObjective but he said that IIS sets file size limits at 30MB by default which just happened to be the threshold for file size when ... read »
May 21, 2013 at 11:51 AM
Ask Ben: Parsing Very Large XML Documents In ColdFusion
Looking at my first ever XML document that I have to parse and put into MS SQL 2000 with CF8. I get it to list the desired Field name, many times over, and have a long list of this field name displa ... read »
May 21, 2013 at 9:25 AM
Turning Off and On Identity Column in SQL Server
you are awesome..i am lucky to get this blog between such a garbage one....Thanks, Prashant ... read »
May 20, 2013 at 4:38 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
@Dana, Your confusion is well founded, since this is a very confusing features. In fact, it ONLY works if you use array notation. Meaning, that this: arrayToList( query[ "columnName" ] ) ... read »
May 20, 2013 at 4:34 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
I was thinking chicken and the egg, I wouldn't have expected it to work in the valuelist going in I guess. Maybe I just need a beer, long day :) ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools