[Hack] Decompile C# source using “dnSpy” and how to prevent it using “ConfuserEx2” or “PreEmptive Dotfuscator”
1. Decompile C# source
1.1 Crack a simple demo C# app
After compile, it is changed to if(true)
Note : Since we re-pack assembly file, so window’ll detect it as virus, so we need to turn off “Virus & threat protection”
1.2 Crack a real business app
1.2.1 Disable login
Copy the succeed login code block then “Edit method”
1.2.2 Disable update
Then save module
2. How to prevent decompile
2.1 Using “ConfuserEx2” (free)
Base Diectory → Select folder
Then select the file we want to protect
Then goto tab “Setting” → Tick “Packer” → select file exe then click “+”
Then goto tab “Protect” → click Protect
Then it’ll generate a new “Confused” folder which contains new protected execution file.
2.2 Using “PreEmptive Dotfuscator” (not free)
Select file to be protected
Setting proper settings from other tabs
Rename : rename all namespaces and const variables → don’t check
Control Flow : exclude changing the processing flow of your programe → don’t check, to make others can’t decompile your code
String Encryption : encode strings i.e : password, connection → check
Removal : Include Triggers to make others can’t compile your code when they try hacking→ check
Linking : use to embedeed dll files into 1 out.exe file (not used in this example)
PreMark : if we encrypt then namespaces can’t know each others, so it can’t intake classes→ don’t check because it’ll break your C# programe. This feature is used only for non-class program and has only 1 single execuetion file.
Click “Build”
Build done
Then it’ll generate a new “Dotfuscated” folder which contains new protected execution file.
Reference: