I'm a little bit confusing about how does zip and unzip software identity whether the file its opening is a zip file or not.
AFAIK, a program can identify a file with extension
.zip is a zip file, and without extension there are some magic bits or MIME type that can be used to determine the file type.
The problem is: if I open a self-extracting executable
.exe file like AMD's driver installer using 7-zip, it still can open the file and the contents are showing correctly. But the "executable" parts are gone. And how does 7-zip determine this file type? Shouldn't the
.exe files have PE headers on Windows?
What's more confusing: I've found that an ISO file can be decompressed using 7-zip, but the 7-zip says it can handle that file type, so it's fine. But if I open the VirtualBox Installer using 7-zip, the file content is like:
.rsrc/ .data .rdata .reloc .rsrc_1 .text CERTIFICATE
These files are the resource file within the exe, and 7-zip reported the file type is
PE, so I guess it is acting like resource hacker and shows the resource files? But not all exe files can be opened in this way, why? And when I opened the Open VPN Installer, the file content is like:
$PLUGINSDIR $TEMP bin doc easy-rsa sample-config icon.ico Uninstall.exe.nsis
And this is basically what I will get after installation except those
$ folders. And the file type is
Nsis, the same as the self-extracting executable
.exe. So I assume they are using the same mechanics, am I right? But why this file is not
PE type? Or the 7-zip is just a Swiss Army knife kind software that can handle any file types? But how does 7-zip identify it?
I've been wondering this question for a long time, any help will be appreciated!