Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proguard injars and libraryjars

I have exported Java SE application with multiple 3rd party libraries using Eclipse's Export as Runnable JAR file menu. How I must set the injars and libraryjar options of Proguard to obfuscate this application?

Like this?

  • injars MyApp.jar

  • injars 3rd party lib

  • injars second 3rd party lib etc

  • libraryjar ${java.home}/lib/rt.jar

  • libraryjar ${java.home}/lib/jsse.jar

  • libraryjar ${java.home}/lib/jce.jar

So I must set the 3rd party libraries as injars and ${java.home}/lib/* as libraryjar?

like image 467
Refugio Harmer Avatar asked May 28 '12 19:05

Refugio Harmer


People also ask

What is the difference between ProGuard and R8?

R8 differs from proguard in the following ways: R8 has higher Kotlin language support as compared to proguard. Proguard is mainly used by applications developed using Java. Usually, the R8 compiler is much faster than the proguard compiler.

What is ProGuard and DexGuard?

ProGuard offers basic protection against static analysis only, while DexGuard shields applications from both static and dynamic analysis. This is an important differentiator as it relates to mobile app security because attackers generally combine two approaches when attempting to reverse engineer an application.


2 Answers

injars contains the jar you want to obfuscate, and libraryjars the 3rd party libs that are not obfuscated.

like image 105
Emmanuel Bourg Avatar answered Sep 22 '22 01:09

Emmanuel Bourg


  • -injars class_path

Specifies the input jars (or aars, wars, ears, zips, apks, or directories) of the application to be processed. The class files in these jars will be processed and written to the output jars. By default, any non-class files will be copied without changes. Please be aware of any temporary files (e.g. created by IDEs), especially if you are reading your input files straight from directories. The entries in the class path can be filtered, as explained in the filters section. For better readability, class path entries can be specified using multiple -injars options.

  • -libraryjars class_path

Specifies the library jars (or aars, wars, ears, zips, apks, or directories) of the application to be processed. The files in these jars will not be included in the output jars. The specified library jars should at least contain the class files that are extended by application class files. Library class files that are only called needn't be present, although their presence can improve the results of the optimization step. The entries in the class path can be filtered, as explained in the filters section. For better readability, class path entries can be specified using multiple -libraryjars options. Please note that the boot path and the class path set for running ProGuard are not considered when looking for library classes. This means that you explicitly have to specify the run-time jar that your code will use. Although this may seem cumbersome, it allows you to process applications targeted at different run-time environments. For example, you can process J2SE applications as well as JME midlets or Android apps, just by specifying the appropriate run-time jar.

My result`

  1. -injars MyApp.jar
  2. -libraryjars ${java.home}/lib/rt.jar
  3. -libraryjar ${java.home}/lib/jsse.jar
  4. -libraryjar ${java.home}/lib/jce.jar

As for 3rd part lib,there has some difference.

The specified library jars should at least contain the class files that are extended by application class files. Library class files that are only called needn't be present

,so 3rd part lib may not need set.

like image 21
Chuanhang.gu Avatar answered Sep 20 '22 01:09

Chuanhang.gu