Control Flow Obfuscation Enterprise
Decompilers reconstruct if/else, for, while, and switch statements by recognizing the shape of branches in the compiled assembly. Demeanor restructures each method body so those shapes no longer correspond to your original logic. The decompiled output cannot be followed back to the source code.
Usage
| CLI | MSBuild | Default |
|---|---|---|
--cfg Flatten | <DemeanorCfgLevel>Flatten</DemeanorCfgLevel> | Maximum (default) |
--cfg Predicates | <DemeanorCfgLevel>Predicates</DemeanorCfgLevel> | Medium |
--cfg Reorder | <DemeanorCfgLevel>Reorder</DemeanorCfgLevel> | Light |
--no-cfg | <DemeanorNoCfg>true</DemeanorNoCfg> | Disable entirely |
Two separate properties: <DemeanorCfgLevel> picks a strength level (Flatten, Predicates, or Reorder), and <DemeanorNoCfg>true</DemeanorNoCfg> disables it outright. Set either one — you don’t need both.
Before & After
YOUR CODE
public void ApplyDiscount(DiscountType type, decimal amount)
{
_discount = type switch
{
DiscountType.Percentage => _basePrice * amount / 100,
DiscountType.FixedAmount => amount,
DiscountType.BuyOneGetOne => _basePrice / 2,
_ => 0
};
}AFTER OBFUSCATION (Flatten)
void a(g a, decimal a)
{
if (1 == 0) { }
decimal num;
switch (a)
{
case (g)3:
num = this.m_a / 2m;
goto IL_0054;
case (g)1:
num = this.m_a * a /
new decimal(0x5A2E3FCA ^ 0x5A2E3FAE);
goto IL_0054;
default:
if ((0x321AE74B & -840623948) == 0)
{
num = 0m;
goto IL_0054;
}
_ = 1 + 1;
throw null;
}
IL_0054:
if (1 == 0) { }
c = num;
}Real ILSpy output. The clean switch expression has become unreadable; combined with constants encryption, the numeric values are gone too.
Obfuscation Levels
- Reorder — light. Small assembly-size increase.
- Predicates — medium. Reordering plus additional disguise of branch outcomes.
- Flatten — maximum protection; the largest size increase. Methods that cannot be safely flattened automatically fall back to Predicates.
When to Disable
- Performance-critical inner loops — Flatten adds modest per-iteration overhead. The JIT mitigates this, but for microsecond-sensitive code consider excluding specific methods.
- Debugging — obfuscated methods are very hard to step through. Use
--no-cfgfor Debug builds.
Ready to protect your .NET code?