使用 ConfuserEx 代码混淆工具保护你的.NET 应用程序
前言
.NET 应用如何防止被反编译?这个对于我们.NET 开发而言是一个值得关注和重视的问题,防止应用程序被反编译的手段有很多本文我们主要讲讲如何使用 ConfuserEx .NET 开源免费的代码混淆工具保护你的.NET 应用程序。
ConfuserEx .NET 混淆工具介绍
ConfuserEx 是一个功能强大且广泛使用的.NET 代码混淆工具。它支持多种混淆技术,包括控制流混淆、字符串加密、资源加密等。它具有灵活的配置选项,可以根据不同的需求进行定制。
注意注意:不足的是目前只支持.NET Framework 2.0/3.0/3.5/4.0/4.5/4.6/4.7/4.8,不支持.NET Core 代码混淆,本章.NET 版本代码示例使用的是.NET Fx4.7.2。
三款免费的.NET 混淆工具推荐
需要支持.NET Core 代码混淆的工具可以看下面这篇文章中介绍的几款免费工具。
https://mp.weixin.qq.com/s/hXGRdQjC7NXiGwq84KbEnA
.NET 反编译相关的文章
ConfuserEx .NET 混淆工具安装
GitHub 开源地址:https://github.com/mkaring/ConfuserEx

ConfuserEx-GUI.zip 包解压即可使用:


使用 ConfuserEx 工具混淆.NET Fx .dll 文件
添加需要混淆的.dll 文件
将待混淆的.dll 文件拖拽进中间方框区域(Drag input modules here),如下图所示:

设置混淆规则
选择 Settings 项,添加混淆规则,如下图所示:

设置混淆规则:Protections 选择 anti ildasm,应该是防止 IL 反编译。因为 Ildasm.exe 是微软提供的.NET 的 IL 反编译器。

选择 Proect!选项开始混淆
点击【Protect!】,就开始混淆了,Finished 代表混淆完成并成功。

混淆成功保存的文件目录:

混淆前后反编译代码对比
混淆之前反编译结果:

混淆之后反编译结果:
一、用 ILSpy 无法打开:

二、用.NET Reflector 反编译结果:

使用 ConfuserEx 工具混淆.NET Fx 混淆.exe 文件
添加需要混淆的.exe 文件

选择 Settings 选项卡,添加混淆规则
注意:这里与.dll 文件设置混淆规则不一样,需要要设置 Packer,压缩打包,且不需要编辑规则。

选择 Proect!选项开始混淆
点击【Protect!】,就开始混淆了,Finished 代表混淆完成并成功。

ILSpy 查看混淆前后的.exe 文件对比
混淆之前:

混淆之后:

运行混淆后的.exe 文件


文章转载自:追逐时光者
评论