Zelix KlassMaster - Java Obfuscator

ZKM Script Language

Although Zelix KlassMaster™ has an easy to use GUI interface, its real power is in its ZKM Script language. ZKM Scripts allow you to automate your obfuscation task and greatly reduce the risk of human error. The ZKM Script language has an intuitive, Java-like syntax and is supported by:
  • A GUI dialog called the ZKM Script Helper that interactively creates basic ZKM Scripts,
  • A preprocessor that allows you to include shared ZKM Script fragments inside other ZKM Scripts,
  • A Build Tool interface for executing ZKM Scripts from within a build tool such as Apache Ant.
See the sample script below but note that it shows only a fraction of the power of the ZKM Script language. For example, using the exclude statement, you can exclude from obfuscation the names of all methods:
  • that are declared in a class that
    • is public and final
    • extends java.util.Observerable
    • implements java.io.Serializable
  • that are annotated with the class com.mycompany.MyAnnotation
  • that take a single String argument
  • that throw java.lang.RuntimeException
  • that are NOT private.
The exclude parameter that has the abovementioned effect is

public final *.* 
   extends java.util.Observerable 
   implements java.io.Serializable 
      @com.mycompany.MyAnnotation
      !private *(java.lang.String)
      throws java.lang.RuntimeException

Please see the ZKM Script Exclusions Tutorial for more detail on the power of the exclusion syntax.

A sample ZKM Script with color coding


/**********************************************************/
/* Sample ZKM Script. Shows only a fraction of the power. */
/**********************************************************/

print "Starting the script";

classpath ".;C:\jdk1.8.0\jre\lib\rt.jar";

open "c:\directory1\Class1.class" //open specific class
     "c:\directory1\MyJar.jar"    //open all classes in jar file
     "c:\directory2"              //open all classes in specific directory
     "c:\directory3\*"; //open classes in directory and its subdirectories

//Exclude class, field and method names from being changed. Uses wildcards.
exclude //Public classes in package "com.mycompany"
        public com.mycompany.* and 
        //Class "com.mycompany.MyClass"
        com.mycompany.MyClass and 
        //Implementors of Serializable
        *.* implements java.io.Serializable and 
        //All methods throwing Exception
        *.* *(*) throws java.lang.Exception and 
        //All classes annotated with MyAnnotation
        @com.mycompany.MyAnnotation *.*; 

obfuscate changeLogFileIn="ChangeLogIn.txt"
          changeLogFileOut="ChangeLog.txt"
          obfuscateFlow=aggressive  //Flow obfuscation level
          encryptStringLiterals=enhanced //String encryption level
          lineNumbers=scramble;          //Use line number scrambling

saveAll "C:\Temp"; //Save the obfuscated classes to "C:\Temp"