Constant Disintegration
Protection ID: constants_mutation
This protection disintegrates the integers of your application in several arithmetic, logical and conditional operations dynamically so that the original value cannot be obtained.
This protection is available in the editions:
Team Scale Enterprise
How It Works
Constant disintegration takes numeric constants in your code and replaces them with complex mathematical expressions that evaluate to the same value at runtime. Instead of seeing the actual numeric values, decompilers will display elaborate calculations involving multiple operations, making it difficult to determine what the original constant was.
This protection transforms simple numeric values like 42
into complex expressions like ((7 * 6) + 3) - 3
. The expressions can include arithmetic operations, bitwise logic, conversion functions, and conditional evaluations, all designed to produce the original value while being difficult to simplify through static analysis.
Parameters
- Intensity integer : Determine the amount of operations that will be generated to disintegrate the values. 1 to 10 2 by default
- Operations string : It allows to select what type of operations will be used to disintegrate the values.
- Arithmetic
- Mathematics Scale Enterprise
- Conditionals
- Logic Scale Enterprise
- External
- Conversion Enterprise
- Disitegration
- Native Enterprise
- Strings boolean : Determines if the strings and text of the application should be disintegrated.
Rules configuration
shield.config.json
{
"protections": {
"constants_mutation": {
"intensity": 2, // From 1 to 10. Default 2.
"operations": "arithmetic|logic|conversion", // string with the selected operations separated by a vertical bar
"mutate strings": true // true or false
}
}
}
Modes
- Default: Disintegrates integer constants based on dynamic operations.
Code example
- Before:
Program.n += 3 * args.Length;
Console.WriteLine($"Hello World ! Current processes {n}");
Console.ReadKey();
- After:
int[] array = new int[] {
767790,
-517058,
38748320
};
checked {
object[] array4 = new object[array3[num4 - num5]];
array4[array[ " ͕ ".Length] * ( -160764 + 829328 > > Convert.ToInt32( "13", 16))] = "ᦐ";
array4[(Convert.ToInt32( "1000011100000110110", 2) | 250883 * 2) ^ Marshal.SizeOf(typeof(MoveBufferArea))] =
unchecked(Marshal.SizeOf(typeof(__9__2_0)) - ((64135 ^ 842523) + checked(438545 - 732342)));
int num6;
if (((18665 % 7466 > Convert.ToInt32( "fffd0bb9", 16)) ? 1 : 0) == 0 / 2133) {
num6 = -767297 - -110690;
}
else {
num6 = ~ - 133694;
}
array7[num6] = (int) array2[((62301 < 630141) ? -255426 : -270726) + (83010 | 172416)]; <
Module >.get_InheritanceFlags(ref str3, array7);
}
Console.WriteLine(str + str2 + str3 + (ConcurrentDictionary__2.add_ReflectionOnlyNamespaceResolve * checked((array[6] > >
(6 | 4)) - unchecked(833425 + -830673) * Convert.ToInt32( "334", 8))).ToString());
Console.ReadKey();
Exclusions
- Exclude with attribute
Include this attribute in your source code:
[Obfuscation(Exclude = false, Feature = "-constants_mutation")]
- Exclude from the interface
You can exclude this protection from methods or classes you want using the Shield configuration interface.
When to Use
Constant disintegration provides powerful protection in these scenarios:
- Algorithms with distinctive constants: When your code contains recognizable mathematical constants or special numeric values
- Parameter validation: Methods that check inputs against specific threshold values
- Licensing or security checks: Validation code that compares against known values
- Game logic: Gaming applications where numeric constants represent game rules or thresholds
- Financial applications: Systems handling monetary calculations or financial thresholds
- Any application with numeric logic: Adds an important layer of protection to any application that uses numeric operations
Shield intelligently applies this protection with optimized settings based on your application type and target platform. The sophisticated engine analyzes your code and applies the appropriate level of protection to each constant, ensuring maximum security with no performance impact.
Constant disintegration works seamlessly with constant encryption. Shield can automatically apply both protections in a complementary way - encrypting your strings and sensitive data with constant encryption, and disintegrating your numeric values for comprehensive constant protection.
Compatibility
Framework | Compatibility | Comments |
---|---|---|
.NET Core | ✔ | |
.NET Framework | ✔ | |
.NET (up to 8 version) | ✔ | |
.NET Standard | ✔ | |
Xamarin IOS | ✔ | |
Xamarin Android | ✔ | |
Xamarin MacOs | ✔ | |
WPF | ✔ | |
Blazor | ✔ | |
.NET Maui | ✔ | |
Unity | ✔ | |
ASP | ✔ | |
Silverlight | ✔ | |
VBa (Visual Basic) or C# (CSharp) | ✔ | |
WinRT | ✔ |
Shield is compatible with all versions of .NET. It automatically adapts to your specific framework, whether you're using .NET 2.0, .NET 4.7, .NET Core 2.1, or Xamarin.Forms 5.0.