Scripting SandMark

SandMark can be run through a CLI interface, or from a shell prompt.



Use the following command to run CLI:
java -cp sandmark.jar sandmark.smash.SandmarkCLI -options

CLI options:
-U : Usage
-S : Display static watermark list
-D : Display dynamic watermark list
-R : Display obfuscator list
-L <level> : Specify obfuscator level to be displayed - 'app'/'class'/'method'
-A <algoName> : Specify algorithm
-H : Get algorithm help
-i <inputJar> : Specify input jar file
-o <outputJar> : Specify output jar file
-w <watermark> : Specify watermark value
-k <key> : Specify key value
-E : Perform embedding
-R : Perform recognizing
-O : Perform obfuscation
-P <prefixStr> : Specify prefix string(for ConstantString watermark)

Dynamic Watermark specific options:
-t : Specify trace file
-c : Set ClassPath
-m : Set MainClass
-a : Set Arguments
-T : start Trace
-N <encodeStr> : Specific parameters for CT/DynamicAA algorithm.



Use the following command to start up SandMark shell:
java -cp sandmark.jar sandmark.smash.Smash

At the $smash prompt, you can give the following shell commands:
Additional options:


Sample_Scripts for SandMark CLI 


 
       #   setenv sandmarkCLI  "java -classpath sandmark.jar sandmark.smash.SandmarkCLI"               $sandmarkCLI -A AddMethField -i TTT.jar -o outputTTT.jar -w 1234 -E -k 1111
              > Embed 1234  in TTT.jar using the static watermark algorithm AddMethField and key value 1111;
                 outputTTT.jar is the watermarked jar file.
          $sandmarkCLI -A CT -i TTT.jar -o TTT.tra -m TTTApplication -T
              > Create a trace file TTT.tra from the input file TTT.jar; TTTApplication is the main class specified
              $sandmarkCLI -A CT -i TTT.jar -t TTT.tra -w 12345 -E
              > Embed the wateramark 12345 in TTT.jar using the tracefile TTT.tra. The default watermaked file is TTT_wm.jar
              $sandmarkCLI -A Method2RMadness -i TTT.jar   -O
              >  Run the Method2RMadness obfuscation on TTT.jar ; TTT_obf.jar is the default obfuscated jar file created.                $sandmarkCLI -A AddMethField -i outputTTT.jar -k 1111 -R
              > Run the recognition for AddMethField algorithm on outputTTT.jar file with key value 1111.




Sample_Scripts for SandMark shell


       # java -classpath sandmark.jar sandmark.smash.Smash
       > Initialize and start sandmark shell. A smash$ prompt will be displayed.
           
           > selectAlg("ConstantString");
           > setInputFile("TTT.jar");
           > setKey("9876");
           > setWM("12345");
           > setPrefix("sm$");
           >embed();

           > selectAlg("DynamicAA");
           > setInputFile("TTT.jar");
           > setTraceFile("TTT.tra");
           > setMainClass("TTTApplication");
           > startTrace();
           > set_min_wparts("2");
           > set_encode_as_constants("true");
           > set_use_opaque_methods("true");
           > set_reuse_methods("false");
           >embed();
                                 > selectAlg("Buggy Code");
          > setInputFile("Ackermann.jar");
          > setOutputFile("AckermannOutput.jar");
          > obfuscate();

           > setInputFile("TTT.jar");
           > embedMultipleWM("AddMethField.1234:BogusExpression.56789:HatTrick.4444");

           > setInputFile("TTT_wm.jar");
           > selectAlg("BogusInitializer");
           > setKey("1111");
           > recognize();