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.
Option | Arguments | Description |
---|---|---|
--Transform | EncodeLiterals | Replace literal integers and strings with less obvious expressions. |
--EncodeLiteralsKinds | integer, string, * | Specify the types of literals to encode Default=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.
|
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 \
...
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).