Alex Rivera | Logout

JAR hidden inside EXE?

Asked 2010-09-20T18:57:43.830
11

Minecraft, a Java game, is free this weekend. The Windows version downloads as an exe file. I was curious what the EXE file is doing and where it's unpacking and running the actual game JAR from. So using a command, I found the command-line arguments to the running javaw.exe process; and oddly enough, it was launched with a classpath pointing to the executable! (meaning, the .exe file was acting as a jar). Indeed, after renaming Minecraft.exe to Minecraft.jar, I was able to open it and see the loader class files and such, as if it were a normal JAR file and not an EXE at all.

How is this possible? And how can I do it with my own JAR files?

Edit
Report

2 Answers

3

after renaming Minecraft.exe to Minecraft.jar, I was able to open it and see the loader class files and such

Some EXE files are in fact self-extracting ZIP files. JAR files are in turn normal ZIP files with a special file structure. I bet that you was just opening it using a ZIP tool after renaming it. Note that some ZIP tools will auto-integrate in Windows explorer (or the other way round) so that it happens seemingly transparently.

answered 2010-09-20T19:08:06.113
2

The ZIP (and by extension, JAR) file format is flexible in that it allows the archive to be embedded inside another file format. This is what makes self-extracting ZIP archives possible (some small code is embedded in areas that the ZIP file parameters ensure are ignored by unzip utilities). It has also been used for some particularly sneaky exploits as well.

My guess is that Minecraft similarly exploited the ability to make the archive a valid Windows executable and added code to launch the JVM with itself in the classpath.

See also: Wikipedia: Combining ZIP with other file formats

answered 2010-09-20T19:23:21.433

Your Answer