C# 混淆编辑
一. 安装obfuscar
obfuscar可以通过Nuget工具方便的安装

二.新建obfuscar配置文件

<?xml version='1.0'?> <Obfuscator> <Var name="InPath" value=".\Obfuscator_Input" /> <Var name="OutPath" value=".\Obfuscator_Output" /> <Module file="$(InPath)\BasicExampleExe.exe" /> <Module file="$(InPath)\BasicExampleLibrary.dll" /> </Obfuscator>
说明:
1.混淆的参数有很多,可以参考https://docs.obfuscar.com/getting-started/configuration.html#settings 进行添加或删减
2.需要混淆模块可以是exe 也可以是dll ,可以一个也可以多个。实际使用时,需要改成自己的exe名字或dll名字
|
Name |
Description |
|---|---|
|
InPath |
Directory containing the input assemblies, such as . |
|
OutPath |
Directory to contain the obfuscated assemblies, such as . |
|
LogFile |
Obfuscation log file path (mapping.txt). |
|
XmlMapping |
Whether the log file should be of XML format. |
|
KeyFile |
Key file path, such as . |
|
KeyContainer |
Key container name. |
|
RegenerateDebugInfo |
Whether to generate debug symbols for obfuscated assemblies. |
|
MarkedOnly |
Whether to only obfuscate marked items. All items are obfuscated when set to . |
|
RenameProperties |
Whether to rename properties. |
|
RenameEvents |
Whether to rename events. |
|
RenameFields |
Whether to rename fields. |
|
KeepPublicApi |
Whether to exclude public types and type members from obfuscation. |
|
HidePrivateApi |
Whether to include private types and type members from obfuscation. |
|
ReuseNames |
Whether to reuse obfuscated names. |
|
UseUnicodeNames |
Whether to use Unicode characters as obfuscated names. |
|
UseKoreanNames |
Whether to use Korean characters as obfuscated names. |
|
HideStrings |
Whether to hide strings. |
|
OptimizeMethods |
Whether to optimize methods. |
|
SuppressIldasm |
Whether to include an attribute for ILDASM to indicate that assemblies are obfuscated. |
|
AnalyzeXaml |
Whether to analyze XAML related metadata for obfuscation. |
三.配置后期生成事件命令行
右击项目选择属性,在生成事件里填入如下内容,
CD $(TargetDir) "$(Obfuscar)" obfuscar.xml xcopy $(TargetDir)*.dll $(TargetDir)Output\ /y
说明:
1. if “%str%”==”Release” 这句是限制了只release版本进行混淆。如果都有混淆,删掉即可。
2. CD $(TargetDir) “$(Obfuscar)” obfuscar.xml 这个两句是cd到生成目录。执行xml 进行配置好的混淆
3. xcopy Obfuscator_Output\*.dll /y /e /i /q xcopy是将混淆后的文件复制到生成目录 覆盖掉原来的问题。注意如果在子项目中运行这两句话,会导致主项目找不到dll 而生成失败。
4 xcopy $(TargetDir)*.dll $(TargetDir)Output\ /y 将debug的dll 复制到 output中
四.直接点击运行即可

浙公网安备 33010602011771号