Recursion Is Its Own Reward
as well as its own punishment.
Unfortunately, on some sites, images you upload get converted to .jpg, regardless of their original format, so this little trick didn’t work out here and downloading it won’t result in a file you can play with.
So, I’ll just have to explain what it’s all about here …
The premise of this technique is to append a .zip file to the end of a .gif file, resulting in a file which is readable by both image manipulation programs and archiving programs.
It works because .gif files keep all of their information in the headers, while .zip files keep them in the footer.
Since that’s the case, .gif viewers read from the front of the file, while .zip readers read from the end.
Here’s how to combine your .gif and .zip.
At the Windows prompt use this command: copy /B source.gif+source.zip target.gif — or under Linux/Mac OS: cat somefile.zip >> somefile.gif
The problem with this method is that not all zip programs can extract the resulting file, but WinRAR handles it just fine.
If you were able to download the original .gif and open it with WinRAR, you would find a text file ‘hidden’ inside.
The content of that text file is:
There’s any number of great ways to hide data from prying eyes — TrueCrypt, anyone?
But if you want to simply hide some text data inside a secret “compartment”, you can abuse the Alternate Data Streams feature in the underlying NTFS file system.
All you have to do is open up a command prompt, and then use a command similar to this:
more < SomeFile.txt:SecretWordHere.txt
The special filename with the colon and second filename tells NTFS to actually store the data in an alternate stream, instead of the regular file.
You can put whatever you want into the file, and nobody will be able to access it unless they know the command to retrieve it.
If you look at the .gif as an image, you’ll see that it’s showing you how to do precisely that.
So, the result of it all was a set of instructions hidden in the .gif by means of a recursive (or self-referential) process that is, quite literally, staring you in the face before you even get at the content — all the content is is an explanation of what it is that you are looking at.
The image is, thus, a container for itself, if you will, and getting at the content the reward for reverse-engineering the process.
Recursion is, therefore … in this instance … quite literally its own reward.
And it’s not just fun, but educational too.