. NET is a language that is built on virtual machines that directly generates the intermediate language of MSIL, and then the. NET compiler JIT interprets the image as native code and delivers CPU execution. Intermediate languages are easy to decompile, so study how to protect DLL files effectively.
My general approach is: Strong signature + obfuscation + encryption.
Strong signature
Strong-Named assemblies ensure that your assembly is unique and not tampered with, and so on, even if the same name of the assembly if the signature is different.
Strong signature is very simple, this site another article has been explained in detail, please refer to: http://www.cn-web.com/shtml/article/net/fxsj/2009/06/16/913.shtml
Note: Unsigned main programs can reference signed or unsigned assemblies; the signed main program cannot reference unsigned assemblies. (The above article has the corresponding solution)
Confuse
Confusion is the compilation of the generated MSIL intermediate code obfuscation, the simplest confusion is the name confusion, the namespace name, class name, method name, field name, and so on are replaced by special symbols or other symbols, the purpose is to let people see faint, but does not change the program execution logic.
The Dotfuscator I use here is confusing.
Dotfuscator Obfuscation Method:
1. Create new projects;
2. Select the DLL and EXE file to be confused;
3. Select the library attribute in the attribute (very important, because I am here to confuse the DLL file, if not selected, confusion will not be called correctly!) ), as shown in the following illustration:
4. Select the Bulid label and click the Bulid button to confuse it.
We can also choose other tags to encrypt strings, add watermarks and other operations, I am here to encrypt the work in another way, so there is no choice operation.
OK, after the confusion is complete, we can use Reflector.exe to decompile the confused DLL file, you can compare the source to see the effect.
Encryption
Next we continue to encrypt the confused DLL file to further protect the DLL file.
The encryption tool I use is maxtocode.
Open the software, switch to Chinese, you can see very simple, add the DLL file, directly click to perform encryption. Other options such as: encrypted string, strong name, etc. are very simple, we will know as soon as we try, and maxtocode help to do very friendly, a look will be used.
The encrypted DLL file is one-fold larger than before, and after Reflector.exe, the DLL file is found to be encrypted more thoroughly because the contents of the main function are hidden.
Through the above three steps, make your DLL file free from the common People's cracked, of course, can not absolutely prevent being cracked.