Obfuscation Agent
During the obfuscation process, Babel can perform a series of tasks based on a set of pre-defined rules, known as the Obfuscation Agent.
The Agent is designed to avoid common issues that can be introduced by obfuscation and which could potentially break the resulting assembly. For example, the Agent can ensure that certain symbols, such as those used in reflection, are not obfuscated. This is because the obfuscation of these symbols can cause issues with the runtime environment and result in errors or crashes.
To accomplish this, the Agent performs a series of tasks against the target assembly. These tasks are preconfigured and can vary in complexity, with some being straightforward, such as checking fields of serializable types, while others involving more advanced techniques, such as MSIL code static analysis.
Here is the list of available Agent task names in Babel Obfuscator
Task Name | Description |
---|---|
Base types | Prevents renaming of types derived from a specified base type |
Code analysis | Prevents renaming of types reserved to code analysis |
Dynamic language | Prevents renaming symbols used by the dynamic language runtime |
Exposed attributes | Prevents renaming of symbols that expose specific attributes |
Razor webapp | Handle obfuscation of Razor webapp |
Reflected enums | Prevents renaming of enum types consumed by reflection |
Reflected strings | Prevents obfuscation of strings consumed by reflection |
Reflected types | Prevents renaming of types consumed by reflection |
Serializable types | Prevents renaming of serializable types |
WinRT types | Prevents renaming of WinRT private types |
The Obfuscation Agent's tasks are continuously updated with each new product release. This ensures that Babel is always up to date with the latest CLR design rules and can accurately determine which symbols should and should not be obfuscated.
By following these pre-defined rules, Babel Obfuscator can ensure that the obfuscated code remains fully functional and free from issues that could potentially break the application.
Overall, the Obfuscation Agent is a critical component of Babel that helps ensure the protection of .NET applications by preventing symbol names from being obfuscated in violation of CLR design rules.
Overriding Agent Rules
The Obfuscation Agent is enabled by default and should be left enabled whenever possible to ensure that obfuscation is performed correctly. Disabling the Agent is generally not recommended because it can cause issues with the runtime environment and result in errors or application crashes. However, in some cases, users may want to disable certain Agent tasks to achieve specific obfuscation results.
It's important to note that the Agent tasks run after the Rules processing phase. This means that any custom XML rule not enforced on a member will be overridden by the Agent task. Therefore, users should carefully consider the impact of disabling or customizing Agent tasks before making any changes to the default settings.
It is possible to skip a specific Agen task using XML Rules. This can be accomplished by defining an exclude rule targeting the agent feature that specifies the task names to skip in the TaskNameList element as a child of the rule Properties element. This will prevent the specified tasks from being run during obfuscation.
For example, to disable the Serializable types and Reflected strings tasks, you would define an XML rule like this:
In this rule targeting the "agent" feature, the exclude attribute is set to "true", which tells Babel Obfuscator not to run the Serializable types and Reflected strings agent tasks when processing the assembly.
Disabling a task from running is not always feasible because it can lead to unexpected runtime issues. Therefore one way to achieve the obfuscation outcome of a specific symbol is using an XML rule that can be enforced by setting the "locked" attribute to "true", which prevents the agent from overriding it.
This rule will enforce renaming for all the classes inside the ACME.Data namespace, including all serializable types.
Last updated