Opaque Predicate Library

Opaque predicates are the major building blocks in the design of obfuscating control transformations. An opaque predicate library exists in the sandmark.util.opaquepredicatelib package which will help Obfuscation Algorithms in constructing OpaquePredicates. Current versions available for usage are

The API is here

Basic insertion technique



The user specifies the basic block before which the predicate has to be inserted. The final result of the operation
is a 1 or 0 being pushed into the stack. This value can be popped from the stack and then used to create an
 'opaquely true' , 'opaquely false' or 'opaquely non-deterministic' predicate.
From implementation point of view, the predecessors of the 'bb_ins_before'  block are redirected to point to the
predicate block.

       This predicate embeds opaquely true or false constructs based on algebraic properties and know facts in
        mathematics. As an example, the expression (x(x+1)%2==0) is opaquely true.
       This predicate creates run time deterministic predicates at the required bytecode position. For example, if
        x is an integer variable passed as parameter to a method, (x >,<,>=,<=,==,!= RandomInt) is inserted at
        the desired position.
       This predicate creates run time deterministic predicate based on the length of the string. If x is a String variable
        passed as parameter to some method, then (x.length >.<.>=.<=,==,!= RandomInt) is inserted.
 
       Used to create a (?null) opaque predicate, for example, if x is an object passed as method parameter, then at the
       requested bytecode position in the method, (x==,!=null) is inserted.
       The basic technique used in the construction of DynamicStructure Predicates is as follows:
       This predicate creates run time deterministic predicate based on  race condition. Multiple instances of a thread class are
       created that access a common class field. The final value of the field depends on the exact sequence of thread access.