XAML Renaming

Windows Presentation Foundation (WPF) and, more recently, MAUI applications use XAML declarative markup language and BAML (compiled XAML) to directly enable visual designers to create user interface elements.

Babel Obfuscator can analyse XAML and BAML resources and rename all the members referenced within them, which increases the percentage of obfuscated symbols and makes the XAML code more difficult to read. Additionally, Babel can merge multiple assembly files containing XAML or BAML resources into a single assembly file, improving the organization and simplifying the deployment of the application.

The XAML and BAML symbols renaming is enabled by entering the --xaml flag at the command line. This switch has additional optional parameters, which can be used to enhance the XAML (BAML) obfuscation.

Command Line

babel.exe myapp.exe --xaml

MSBuild Babel Task

<PropertyGroup>
  <ObfuscateXaml>true</ObfuscateXaml>
</PropertyGroup>

<Babel ObfuscateXaml="$(ObfuscateXaml)" />

Babel Obfuscator allows some advanced XAML settings for additional configuration of the XAML obfuscation process by using key-value pairs passed after the --xaml switch.

Available key-value pairs include:

keys

In XAML, a static resource is a resource that is defined at design-time and can be referenced from other parts of the application, such as controls or styles. The resource is identified by a key name used to reference it from the XAML code.

When enabled, Babel Obfuscator will rename the key names of static resources in the XAML/BAML code. This can help increase the level of obfuscation of the code and make it more difficult for attackers to understand the original purpose of a resource.

res

When enabled, allows Babel to obfuscate the XAML/BAML resource names. This means that the names of any resources used in the XAML/BAML code, such as images or strings, will be renamed to obscure their original purpose. This can make it more difficult for attackers to understand the structure and function of the XAML/BAML code, which can improve the overall security of your application.

strip

This option is used to remove line information and white spaces from the obfuscated XAML/BAML code. This can make it more difficult for attackers to reverse engineer the original code, as it removes debug information that could potentially help an attacker reconstruct the original source code. Removing line information and white spaces can also help to reduce the size of the obfuscated XAML/BAML file, making it more efficient and faster to load.

manual

By default, Babel Obfuscator automatically obfuscates all public members referenced within the XAML or BAML code. However, in cases where a more fine-tuned approach is necessary, the manual option can be enabled. This allows the user to manually specify which public members should be obfuscated, using either quick rule or XML rule files. This gives greater control over the obfuscation process but requires more configuration by the user.

babel.exe myapp.exe --xaml keys=on --xaml res=on --xaml strip=on
<PropertyGroup>
  <ObfuscateXaml>keys=true;strip=true;manual=false;res=true;true</ObfuscateXaml>
</PropertyGroup>

<Babel ObfuscateXaml="$(ObfuscateXaml)" />

Last updated