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" //load a specific class
     "c:\directory1\MyJar.jar"    //load all classes in a jar file
     "c:\directory2"              //load all classes in a specific directory
     "c:\directory3\*"; //load all classes in a directory and its subdirectories

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

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

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