Control Flow Obfuscation
Control flow obfuscation makes a method hard to follow by rewriting the way its instructions branch, while leaving what the method computes unchanged. Babel can make if statements harder to read, insert branches that never affect the result, and rebuild a method around a dispatcher so its blocks no longer run in source order. The goal is to raise the cost of decompiling and understanding the code, making it harder to reverse engineer or tamper with.
Babel groups its control-flow work into a set of algorithms you enable individually. They fall into two families:
- Lightweight transforms —
ifandgoto— add branches and extra conditions with almost no runtime cost. - Flattening transforms —
switch,case,call,value, and the Ultimate Chained State algorithm — rebuild a method around a dispatcher. These are much stronger, at a higher runtime cost.
Two further options, token and underflow, deliberately produce non-verifiable IL and are disabled automatically when targeting .NET and .NET Core. See Algorithms for the full catalog.
Configuring Control Flow Obfuscation
Control flow obfuscation can be configured from the Command Line, the MSBuild Babel task, or Babel Desktop. With XML rules you can tune the algorithms for specific sets of methods, for example to change the number of iterations or to enable or disable individual algorithms per method.
Command Line
babel myapp.exe --controlflow goto=on --controlflow if=on --controlflow switch=on --controlflow case=on --iterations 3The --controlflow option enables the specified algorithms — here goto, if, switch and case — and --iterations sets how many times each algorithm is applied to a method.
MSBuild Babel Task
<PropertyGroup>
<ControlFlowObfuscation>goto=true;if=true;switch=true;case=false;call=true;
value=false;token=false;underflow=false;true</ControlFlowObfuscation>
<ILIterations>5</ILIterations>
</PropertyGroup>
<Babel ControlFlowObfuscation="$(ControlFlowObfuscation)"
ILIterations="$(ILIterations)" />The ILIterations property sets the number of iterations for the control flow algorithms.
Babel Desktop
- Open the project in Babel Desktop and select the assembly on the project canvas.
- In the Control flow group of the properties panel, enable
ControlFlowObfuscationand select the algorithms you want to use. - Set
ILIterationsto the number of iterations each algorithm should perform. - Press Run to start the obfuscation.
When obfuscation completes, the Results view shows the control flow statistics: the methods transformed and the iterations performed by each algorithm and, when full statistics are collected, the cyclomatic complexity before and after the transformation.
In This Section
- Algorithms — every control-flow algorithm, what it does, and when to use it.
- Chained State Ultimate — an advanced flattening algorithm hardened against automated control-flow deobfuscation.
- Performance & Tuning — how each algorithm affects runtime, a side-by-side comparison, iterations, and how to keep hot methods fast.