让代码逻辑更难被读懂
结合重命名、字符串加密和控制流混淆,让分析者更难从分发的程序集中理解代码意图。
按项目需要组合重命名、字符串加密和方法虚拟化,并在 CLI 构建中复用保存的设置。
无需订阅 · 一次购买查看代码排除示例Windows x64 · 桌面界面与 CLI
频繁调用的方法、需要保留名称的字段,都可以设置排除规则。通过 C# 和 VB.NET 示例了解具体用法。
使用 C#、VB.NET 等语言构建的托管 DLL 和 EXE 会保留 IL 和元数据。反编译器可据此还原可读的计算逻辑和字符串。下面的示例展示了方法虚拟化与字符串加密如何改变反编译结果。
折扣、运费计算以及提示字符串直接显示。
同一示例的计算逻辑显示为 VM 调用,提示字符串显示为受保护的读取调用。
internal static class PriceCalculator
{
internal static int CalculateTotal(
int unitPrice,
int quantity,
bool isMember)
{
int subtotal =
unitPrice * quantity;
int discount = isMember
? subtotal / 5
: subtotal / 20;
int shipping = subtotal >= 50000
? 0 : 3000;
return subtotal - discount
+ shipping;
}
internal static string DescribeDiscount(bool isMember)
{
string discountMessage = isMember
? "Member discount: 20%"
: "Standard discount: 5%";
return discountMessage;
}
}Friend NotInheritable Class PriceCalculator
Friend Shared Function CalculateTotal(
unitPrice As Integer,
quantity As Integer,
isMember As Boolean
) As Integer
Dim subtotal As Integer = unitPrice * quantity
Dim discount As Integer = If(isMember,
subtotal \ 5, subtotal \ 20)
Dim shipping As Integer = If(subtotal >= 50000, 0, 3000)
Return subtotal - discount + shipping
End Function
Friend Shared Function DescribeDiscount(
isMember As Boolean
) As String
Dim discountMessage As String = If(isMember,
"Member discount: 20%", "Standard discount: 5%")
Return discountMessage
End Function
End Class加密的是赋给变量的字符串值,而不是变量名称。为了便于观察字符串的变化,返回折扣提示的方法未应用 VM 保护。
增加分析代码逻辑的难度,验证应用的实际运行情况,并在后续构建中复用设置。
结合重命名、字符串加密和控制流混淆,让分析者更难从分发的程序集中理解代码意图。
预览部署文件,并通过名称映射还原混淆后堆栈跟踪中的原始名称。为每个发布版本保留对应的映射文件。
将界面中选择的设置保存为项目,通过 CLI 复用。无需每次重新选择选项,即可将保护步骤加入现有构建流程。
对关键计算应用方法保护,对字符串和资源应用加密。对于频繁执行的代码,请与原始版本比较运行速度,再调整保护范围。
图片为功能原理图。实际结果取决于程序集和设置。
对高频计算、按名称访问的字段等需要兼顾速度或兼容性的部分,可以单独设置排除。在相应声明上添加 Obfuscation 特性,即可继续保留项目中其他代码的保护设置。
适用于名称被持久化数据或反射使用的字段。其他符合条件的字段仍可能被重命名。
using System.Reflection;
internal sealed class AppState
{
[Obfuscation(Exclude = true, Feature = "renaming")]
private string persistedId = "";
private int workingCount;
}Imports System.Reflection
Friend NotInheritable Class AppState
<Obfuscation(Exclude:=True, Feature:="renaming")>
Private persistedId As String = ""
Private workingCount As Integer
End Class适用于需要检查字符串首次读取耗时的方法,例如启动页面。该方法中的字符串字面量不会由此选项加密。
using System.Reflection;
[Obfuscation(Exclude = true, Feature = "strings")]
private static string StartupLabel() => "Ready";Imports System.Reflection
<Obfuscation(Exclude:=True, Feature:="strings")>
Private Shared Function StartupLabel() As String
Return "Ready"
End Function可用于频繁调用的计算方法,并比较保护前后的运行结果和耗时。
using System.Reflection;
[Obfuscation(Exclude = true, Feature = "controlflow")]
private static int HotPath(int value) => value * 3;Imports System.Reflection
<Obfuscation(Exclude:=True, Feature:="controlflow")>
Private Shared Function HotPath(value As Integer) As Integer
Return value * 3
End Function只排除 VM 时,方法体加密或调用隐藏仍可能生效。需要保留普通 IL 的方法应同时指定相关功能。
using System.Reflection;
[Obfuscation(Exclude = true,
Feature = "ilcodehiding;virtualization;code;calls")]
private static int RenderLoopStep(int value)
=> value * 2;Imports System.Reflection
<Obfuscation(Exclude:=True,
Feature:="ilcodehiding;virtualization;code;calls")>
Private Shared Function RenderLoopStep(value As Integer) As Integer
Return value * 2
End Function这些示例用于调整所选代码的保护范围。调试器检测、文件完整性检查等应用级功能,需要在项目设置中修改。
查看排除方法和运行速度检查步骤首次启动即开始 7 天试用,可直接测试自己的程序集。离线电脑也能使用。
按需查看首次保护、构建自动化和问题排查的步骤。
通过 7 天免费试用,比较应用保护前后的运行结果和速度。Windows x64 安装程序已包含所需的 .NET 运行时。
试用期从首次启动起为7天。试用版生成的保护文件可在生成后14天内运行,仅供评估,请勿用于客户分发。正式发布时,请激活付费许可证,再从原始构建重新执行保护。
v1.0.34 · SHA-256 eead066f08d9d9b629d0768b8d72e967183942f426566243d613296c47cc46e5
发行版 Confuser Studio 在启动时若检测到受监测的反编译或分析工具正在运行,就会立即退出。为自己的应用启用“检测到受监测调试器时退出”选项后,受保护的程序也会在检测到这些工具运行时自动退出。
在试用中确认应用的功能和运行速度后,即可购买正式许可证,继续进行发布工作。
每份许可证适用于一台电脑,包含购买后两年内发布的更新。更新期限结束后,仍可在同一台电脑上继续使用期限内有权使用的最后一个版本。