Encode Literals

Obfuscate integer and/or string literals (such as 42 or "42"). Literal integers can be replaced with opaque expressions, which requires that the InitOpaque transformation has been previously issued. Literal strings can be replaced with a function that generates them at runtime.

OptionArgumentsDescription
--Transform EncodeLiterals Replace literal integers and strings with less obvious expressions.
--EncodeLiteralsKinds integer, string, * Specify the types of literals to encode Default=integer,string.
  • integer = Replace literal integers with opaque expressions
  • string = Replace literal strings with calls to a function that generates them
  • * = Same as integer,string
--EncodeLiteralsEncoderName string The name of the generated encoder function (only for encoded strings). Default=None.
--EncodeLiteralsMaxLevel INTSPEC How deep to recurse into split integer expressions. Default=100.
--EncodeLiteralsMaxTransforms INTSPEC How many transformations to perform on each split integer expression. Default=100.
--EncodeLiteralsIntegerKinds opaque, split Specify how to encode integer literals. Default=opaque.
  • opaque = Replace literal integers with opaque expressions
  • split = Replace literal integers by splitting into subparts, and then doing EncodeArithmetic on them.

Regions

You can apply this transformation to a part of a function. First, include tigress.h as usual, then enclose the regions you want to transform using the ENCODE_INTEGER_BEGIN and ENCODE_INTEGER_END macros:

#include "tigress.h"

void foo () {  
   ...

   ENCODE_INTEGER_BEGIN(obfuscateThis);

   int x = 1234567;

   ENCODE_INTEGER_END(obfuscateThis);

   ...

   ENCODE_INTEGER_BEGIN(obfuscateThat);

   int y = 7654321;

   ENCODE_INTEGER_END(obfuscateThat);

   ...
}

The arguments to the macros (obfuscateThis and obfuscateThat) are tags that you specify in the -Regions=... option in your tigress command:

tigress ... \
   --Transform=EncodeLiterals \
      --Functions=foo \
      --Regions=obfuscateThis,obfuscateThat \
      --EncodeLiteralsIntegerKinds=split \
   ...
 

Issues

Note that the generated string encoding function is trivial, by design. To be made less conspicuous, it should itself be transformed, for example using the Virtualize transformation (to hide the string contents) and the RndArgs transformation (to hide the interface).