Custom Attributes
Babel supports declarative obfuscation using the custom attributes System.Reflection.ObfuscationAttribute and System.Reflection.ObfuscateAssemblyAttribute provided by the .NET Framework and .NET.
The ObfuscateAssembly Attribute
The System.Reflection.ObfuscateAssemblyAttribute, is an assembly-level attribute that instructs Babel Obfuscator to use obfuscation rules reserved for private assemblies.
A private assembly is an assembly that will not be used as a library: no other software components will use the assembly. Babel fully obfuscates private assemblies, which will rename all public symbols.
The Boolean constructor argument assemblyIsPrivate=true tells Babel that the assembly is used within the scope of one application and the public interface can be safely renamed.
The Obfuscation Attribute
The System.Reflection.ObfuscationAttribute attribute can be used on assembly members like types, methods, events, properties and fields to configure the action taken for a specific obfuscation feature.
The Obfuscation attribute has the following properties:
Feature
The Feature property maps a string value to a specific obfuscator feature or a list of features. The default value for the Feature property is “all”.
Babel uses “all” to map the complete set of available features. and “default” to map the renaming feature.
Please refer to the obfuscation feature table to know more.
Exclude
Indicates whether the obfuscation feature should be excluded for the associated member.
ApplyToMembers
Specifies whether the action taken by the obfuscator for the associated type should be applied to all its members.
StripAfterObfuscation
Specifies whether the attribute should be removed after processing.
The following code example shows how ObfuscationAttribute can be used to target a method to enable code encryption:
Extended Feature Syntax
Babel Obfuscator supports an extended syntax for feature strings that will allow setting feature properties as a list of key-value pairs after the name of each feature.
The extended Feature syntax will allow setting the ObfuscationAttribute at the assembly level to configure features for the entire assembly:
Renaming
Obfuscation Agent
Disable the obfuscation Agent for Serializable types and Reflected enum tasks.
Value Encryption
Encrypts values and arrays of methods having several instructions between 10 and 100.
The Obfuscation attribute alone is not sufficient to activate the chosen feature. The attribute can only function if the feature is globally enabled in the configuration.
Other Examples
Do not obfuscate compiler-generated code.
Last updated