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 (Obfuscar)” obfuscar.xml 这个两句是cd到生成目录。执行xml 进行配置好的混淆
3. xcopy Obfuscator_Output\*.dll /y /e /i /q xcopy是将混淆后的文件复制到生成目录 覆盖掉原来的问题。注意如果在子项目中运行这两句话,会导致主项目找不到dll 而生成失败。
4 xcopy (TargetDir)Output\ /y 将debug的dll 复制到 output中
四.直接点击运行即可
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~