Since the .net obfuscator is used in the project, many models are searched online, such as Dotfuscator, xeoncode, foxit, etc.
But most of the fees, of course, there are cracked versions, and the company requires that pirated software cannot be used.
After searching for a long time, I finally found ConfuserEX, and it was okay to use, so I quickly took it out and shared it with you.
Since there are few Chinese introductions on the Internet, I will do a test here to demonstrate to you:
1. Create a new C# class library, I won't change the name, just call it ClassLibrary1, and add a simple method under the Class1.cs class:
2. Create another console application ConsoleTest, add a reference ClassLibrary1.dll, and call the test method in ClassLibrary1.Class1 in the Main method:
After compiling, open the ConsoleTest.exe with ILSpy, and you can see the source code as shown below:
3, Now let's try to confuse with ConfuserEx:
After downloading ConfuserEx, unzip it and open the ConfuserEx.exe, as shown in the following figure:
4. See the prompt "Drag input modules here"?
Then put the ConsoleTest.exe just now, as shown in the picture below:
5. Click Settings
- Select Packer
- Modules->ConsoleTest.exe
- Click the + sign for Rules, true
As shown below:
6. Click Protest!->Protect! , prompting successful export (in the Confused directory),
7. Open with ILspy... Confused, look at ConsoleTest.exe the source code:
If the method is empty, copy the ClassLibrary1.dll of the ConsoleTest.exe dependencies to the Confused directory, click Run ConsoleTest.exe, and output the correct result.
Note
8. If you just confuse the exe file, this is fine, if you just confuse a dll file, you will see the following error:
Error: No executable module, no executable body?
Is there no exe file? Let's put the ConsoleTest.exe in and confuse it with ClassLibrary1.dll, look.
9. According to the previous method, I dragged and dropped the ConsoleTest.exe and ClassLibrary1.dll into ConfuserEx to confuse them together.
As shown below:
Prompt success.
10. But we opened it again... confused, found only confused ConsoleTest.exe files, where did ClassLibrary1.dll go?
Can't you confuse the dll file?
Don't worry, let's click ConsoleTest.exe try, oh, I'm going, it runs successfully, as shown in the picture below:
The only explanation here is that ConfuserEx embeds the dll into the exe.
Now the confused ConsoleTest.exe is 17KB, while the original ConsoleTest.exe is 5KB, and the ClassLibrary1.dll is also 5KB.
11. Let's use ILSpy to see the ConsoleTest.exe generated after confusing ConsoleTest.exe and ClassLibrary1.dll at the same time.
I can't see the method, nor can I see the referenced dll file.
Well, that's it for today.
Attached: Since I didn't find a way to confuse the dll separately at noon, this student found a way in the afternoon @四毛的家, and I will add how to confuse the dll separately.
According to step 8, we found that an error was reported when confusing the dll according to the EXE method, and we should have followed the steps below:
After dragging the dll into ConfuserEx, you can't select Packer in the Settings, but click the pencil button on the right, as shown below.
After clicking the pencil button, the Edit rule dialog box pops up, select one item in the Preset, I select Maximum here, and then click the "+" button below, select anti ildasm (I guess to prevent compilation through IL), and then the export is successful.
We are using ILSpy to check the ClassLibrary1.dll that has just been confused, as shown in the figure below,
Nothing can be seen.
To test the obfuscated dll available, I put the unobfuscated ConsoleTest.exe and the obfuscated ClassLibrary1.dll in one directory, click Run ConsoleTest.exe, and succeed.
|