Skip to content

Substitution — substitution

Instruction substitution and diversification. Replaces individual instructions with semantically equivalent — but structurally different — idiom sequences (e.g. rewriting a + b as a - (-b), and many more), optionally over several rounds.

Cheap, broadly applicable, and a good first layer under mba: substitution diversifies the instruction stream while MBA tangles the arithmetic.

Options

Key Default Range Meaning
prob 50 0–100 Probability (%) to substitute at a candidate site.
loop 1 1–10 Number of substitution rounds.
maxSites / max / sites 0 0–100000 Cap on substituted sites (0 = auto).

Example

__attribute__((annotate("obf: substitution(loop=2,maxSites=250)")))
int calc(int x, int y) { return x + y - (x & y); }

Rounds multiply variety

Each loop round can re-substitute the output of the previous one, so loop=2 produces markedly more varied sequences than loop=1 at a modest size cost.