Download User's Guide
Transcript
51 Obfuscate Multiple Assemblies The obfuscation process itself can only rename the internally visible assembly symbols, leaving the public members untouched. Otherwise the runtime execution of assemblies that consume the obfuscated types will be compromised. Babel can obfuscate public members in multiple assemblies, fixing the name of obfuscated symbols referenced in each assembly. Multiple-assembly obfuscation is made possible by means of map files. Map files are XML files produced as output from the obfuscation process, and contain all the associations between original and obfuscated symbol names. When using map files, it is possible to recover the original symbol names from the obfuscated ones. Map files must not be deployed with the obfuscated application under any circumstances. Keep them private. Consider the following example of a managed application (Calculator.exe) that references two assembly libraries: Algorithms.dll and Math.dll. Suppose that Algoritms.dll references Math.dll also. The reference graph is represented as follows: Calculator.exe Algorithms.dll Math.dll The two referenced assemblies: Algorithms.dll and Math.dll are general-purpose assemblies, used in several other projects. We want to obfuscate the entire project without merging the referenced libraries, as they are used by other applications as well and not just Calculator.exe. We want to keep the deployed package size as small as possible, and exclusion of referenced assemblies will assist with that. Algorithms and Math assemblies contain many public classes, so to effectively obfuscate the whole project we’d like to mangle public members as well. Babel can address this issue by generating an obfuscation map file for each referenced assembly that will have its public member obfuscated and use those map files when obfuscating the main application assembly or every other assembly with references back to public obfuscated assemblies. To set up the obfuscation process, first we need to tell Babel to obfuscate all public symbols of Math.dll and Algorithms.dll assemblies. This can be done by inserting into the source code the following assembly-level custom attribute declaration: [assembly: System.Reflection.ObfuscateAssembly(true)] This attribute provides a way to configure Babel to obfuscate public symbols without using external configuration files. Setting the Boolean constructor parameter to true specifies that the assembly is private so that public member names can be safely obfuscated. If you don’t want to change the source code you may even create an XML rules file that forces the obfuscation of public member names: