. Net is a language based on virtual machines. It directly generates the msil intermediate language, and then the. NET compiler JIT interprets the image as a local machine.CodeAnd deliver the CPU for execution. The intermediate language is easily decompiled, so we will study how to effectively protect DLL files.
My general method is:Strong signature + obfuscation + encryption.
Strong Signature
Strong namingProgramSet to ensure that your assembly is unique without being tampered with or fraudulent use, even if the Assembly with the same name is different if the signature is used.
Strong signature is very simple, another one on this siteArticleHas been explained in detail, see: http://www.cn-web.com/shtml/article/net/fxsj/2009/06/16/913.shtml
Note: The unsigned main program can reference signed or unsigned assembly, but the signed main program cannot reference the unsigned assembly. (There are corresponding solutions in the above article)
Obfuscation
Obfuscation is to blur the msil intermediate code generated by compilation. The simplest obfuscation is name obfuscation, the purpose of changing the namespace name, class name, method name, field name, and so on to special or other symbols is to make people dizzy, but does not change the program execution logic.
I am using dotfuscator for obfuscation.
Dotfuscator obfuscation method:
1. Create a new project, as shown in:
2. Select the DLL and exe files to be confused, as shown in:
3. Select the Library Attribute in the attribute (it is very important because I want to confuse the DLL file here. If it is not selected, it cannot be called correctly after obfuscation !), As shown in:
4. Select the bulid label and click the bulid button for confusion.
We can also choose other tags to encrypt strings, add watermarks, and other operations. Here I use another method for encryption, so no operation is selected.
OK ,after completion, we can use reflector.exe to decompile the mixed DLL file. We can compare the source code to see the effect.EncryptionNext, we will continue to encrypt the obfuscated DLL files to further protect the DLL files.
The encryption tool I use is maxtocode.
After you open the software, switch to Chinese. You can see that it is very simple. After adding the DLL file, click execute encryption. Other options, such as encrypted strings and strong names, are easy to use. You will find them at a glance, and the help of maxtocode is very friendly. After reflector.exe is decompiled, it is found that the DLL file is encrypted more thoroughly because the content of the main function is hidden. Through the above three steps, your DLL file can be free from cracking by the average person, of course, it is impossible to absolutely prevent being cracked.