You ever wanted to create a "hidden" ZIP File which still can easily be opened? Here is a solution for you:
Create your ZIP File, then create a "container" file, in my case i used an PNG image.
Now append the ZIP to the PNG:
cat test.png test.zip >> test_out
If you now check the filetype of the created file, it will be PNG!
$ file test.zip test.zip; Zip archive data, at least v1.0 to extract $ file test.png test.png; PNG image, 238 x 180, 8-bit/color RGB, non-interlaced $ cat test.png test.zip >> test_out $ file test_out test_out; PNG image, 238 x 180, 8-bit/color RGB, non-interlaced
but you can still use common programs to extract the ZIP file from
test_out and you can still view the png image with no problem.
Why? Because most programs to identify filetypes only take a look at the file-magic (which is at the beginning).
For PNG files it is
47 4E 50 89 (Little Endian), and if you take a look at the beginning of the
test_out file, you see excactly that.
Now what about the ZIP file? ZIP Files also have a magic, but parsing ZIP files is a little bit different. Most programs will start from the end
of the file and search for a central directory entry (looking for the byte sequence
06 05 4B 50 (Little Endian)) and then parse these entries to find
the local headers (byte sequence
03 04 4B 50). But most filetype identification will look for this local header in the front of the file,
but there is none, so the identification for the ZIP file will fail (and of course PNG is shown, because there is a png header).
If you yell at me like "you will not hide anything with it!" you are right. This method is just to understand the different types of file parsing and understand the process of filetype identification.
To see whats happening, i attached the pngzip file here: