Anti ILDasm
Protection ID: anti_ildasm
This protection marks the module with an attribute that prevents ILDasm.
This protection is available in the editions:
Team Scale Enterprise
How It Works
Anti-ILDasm protection adds the SuppressIldasmAttribute
to your assembly, which instructs Microsoft's IL Disassembler (ILDasm) to refuse opening the assembly. This attribute is recognized by Microsoft's official tools and helps prevent the most basic form of .NET decompilation.
When someone attempts to open a protected assembly with ILDasm, they will receive an error message stating that the assembly cannot be disassembled. This provides a first line of defense against casual inspection of your code.
The 'Anti_ildasm' protection will not take effect for .NET 6 or newer versions, according to the official documentation.
Using 'Anti_ildasm' will be compatible with older versions, such as .NET 5 or earlier. However, if your application is .NET 6 or newer, this protection will be ineffective. Instead, use other Shield protections to prevent decompilation.
Parameters
This protection has no parameters or settings.
Rules configuration
shield.config.json
{
"protections": {
"anti_ildasm": {}
}
}
Modes
- Default: Mark the module with the attribute SuppressIldasmAttribute.
Code Example
This protection is applied at the assembly level and doesn't require specific code changes. It functions by adding the following attribute to your assembly:
[assembly: System.Runtime.CompilerServices.SuppressIldasmAttribute()]
The attribute is added automatically by Shield during the protection process, so you don't need to add this code yourself.
Exclusions
- Exclude with attribute
Include this attribute in your source code:
[Obfuscation(Exclude = false, Feature = "-anti_ildasm")]
- Exclude from the interface
You can exclude this protection from specific assemblies using the Shield configuration interface.
When to Use
Anti-ILDasm protection is beneficial in these scenarios:
- Any .NET application: Provides an effective first layer of protection against basic disassembly tools
- .NET Framework applications: Perfect complement to other protections for comprehensive security
- .NET Standard libraries: Protects libraries that are referenced by multiple applications
- Public API assemblies: Helps shield publicly accessible components from easy inspection
This protection is part of Shield's defense-in-depth strategy. Shield automatically adjusts and optimizes this protection based on your target framework and application type, ensuring the right level of protection without any configuration needed.
For maximum protection, combine Anti-ILDasm with other Shield protections like Control Flow, Rename, and Invalid Metadata. Shield will automatically apply the optimal configuration based on your application's requirements.
Compatibility
Framework | Compatibility | Comments |
---|---|---|
.NET Core | ✔ | |
.NET Framework | ✔ | |
.NET (up to 8 version) | ✔ | Ineffective for .NET 6+ |
.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.