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
- Algebraic Predicates
- RuntimeInteger Predicates
- RuntimeString Predicates
- RuntimeIsNull Predicates
- DynamicStructure Predicates
- Thread Contention based Predicates
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.
- Runtime Integer Predicates
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.
- Runtime String Predicates
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.
- Runtime IsNull Predicates
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.
- Dynamic Data Structure Predicates
The basic technique used in the construction
of DynamicStructure Predicates is as follows:
- Add to the obfuscated application code which builds a set of
complex data structures.
- Keep a set of pointers to these structures.
- Based on request by the user to generate a specific type of
predicate, i.e. opaquely true/false or non-deterministic, do
some operations like merging/splitting node groups, inserting node
groups, moving node pointers, but maintaining certain invariants used
in the construction of these opaque predicates such as 'pointers p,q
will never refer to the same memory' and so on.
- Thread Contention
Predicates
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.