HOWTO: Maximize protection of your application against reverse engineering
Article ID: 000023 PDF Version: 000023.pdf The information in this article applies to:
The document explains how to use Excelsior JET most effectively for the protection of your applications against reverse enginering. Project files and build/run scripts for this article may be found here. There are a number of Java decompilers on the market that produce amazingly readable source code, thanks to the high-level nature of Java bytecode and presence of reflection information in class files. As a consequence, there are even more tools called obfuscators, which can rename classes, fields and methods consistently throughout your application and possibly change the control flow so as to fool or break the decompilers, while preserving the application’s functionality. An obfuscator can surely make the decompiled source somewhat less comprehensible, but control flow obfuscation negatively impacts performance and can make classes unverifilable. With Excelsior JET, you ship your Java applications as optimized binary executables. If you also use a name obfuscator to rename classes and members, your application will be as hard to reverse engineer as an equivalent C++ program passed through an optimizing compiler. If all classes of your application are available to Excelsior JET and loaded by one of the default classloaders (system or application), it may be fully protected using Ahead-Of-Time (static) compilation. In the general case, however, you may have to ship some of the orginal class files. In particular, Excelsior JET may not statically precompile classes that are loaded by a custom classloader except by fusing the JIT cache. And even if you ship a precompiled JIT cache, the original classes must still be available at run time to enable consistency checks. As a result, if your application heavily relies on custom classloading, Excelsior JET will not be able to protect it against decompilation. One example of such application is Eclipse, which consists of a small launcher that loads numerous plugins using custom classloaders. Another common case is applications using the Java Security API, which requires the original class files of security providers to be present at runtime. If you are using a third-party security provider other than those included in the Sun JRE, you have to ship its jar with your application. Suppose you have already set up an Excelsior JET project file for your application. You can further improve its protection by taking the following measures:
In order for the Reflection and JNI APIs to function properly, an executable generated by Excelsior JET must contain names of all compiled classes, methods and fields. If exposing these names is not desirable, you can replace them with meaningless character sequences like a0, a1, a2, etc. prior to native compilation using a third-party Java obfuscator. Of course, you would have to manually disable renaming of classes and members that are accessed via reflection or JNI at run time. It is not possible to determine automatically whether a class or member name must not change in most cases. Warning: Beside renaming, many obfuscators are capable of optimizing bytecode and/or obfuscating control flow. Use of these features may substantilly reduce the strength of optimizations implemented by Excelsior JET AOT and JIT compilers or even force them to degrade to the non-optimizing mode. It is also not recommended to let your obfuscator remove unused classes, fields and methods. Ideally, you should set up your obfuscator so that it only changes class and member names and leaves the rest of a class file intact. After name obfuscation, make sure your program works as expected on the Sun HotSpot JVM before compiling it with Excelsior JET. We leave it up to you to decide whether to obfuscate control flow in class files that you need to ship with your application for reasons outlined in the section “Application domain” above.
You do not need to buy any expensive tool to rename classes and members. We have observed good results with the open source ProGuard obfuscator. Below is a sample ProGuard configuration file for the SwingSet2 demo, which you may use as a starting point for obfuscating your application.
Copyright © 2003-2006 Excelsior LLC. All rights reserved.
|
|
Home | Company | Products | Services | Resources | Blog | Contact | Request a Call Site: Search | Forum | Credits © 1999-2006 Excelsior LLC. All Rights Reserved. |