Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obfuscate Class Names With Main Methods

Tags:

java

proguard

I'm using ProGuard to obfuscate executable .jar files. When I decompile the code using Procyon the classes with main methods still have their original names. This is due to

-keepclasseswithmembers public class * {
    public static void main(java.lang.String[]);
}

in the default configuration.

If I remove this, ProGuard won't process. Is there a way to obfuscate class names with main methods as well or is there a good reason against it?

like image 971
BullyWiiPlaza Avatar asked Aug 26 '26 16:08

BullyWiiPlaza


1 Answers

If you obfuscate the classname with the main method, you can no longer call that class to run the jar.

In theory, you could modify the MANIFEST.MF in the jar to refer to the obfuscated classname, but I'm not sure the benefit of that, since it is pretty clear what you are calling at that point.

Further, you can never obfuscate the main(String[]) method name itself, or java can't find and run your application at all. That's a pretty good reason against it :)

If you want to obfuscate the rest of the class members, but keep the classname and main method itself, you can do that with

-keep public class mypackage.MyMain {
    public static void main(java.lang.String[]);
}

as per the first example in proguard manual.

like image 99
Ben Avatar answered Aug 28 '26 07:08

Ben



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!