File tree Expand file tree Collapse file tree 5 files changed +91
-7
lines changed Expand file tree Collapse file tree 5 files changed +91
-7
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,14 @@ Obfuz提供了极其丰富的配置选项和灵活的混淆规则配置文件,
121
121
| Encryption level| 加密级别,取值范围为` [1, 4] ` ,默认为1。 加密级别越高,加密越复杂,解密也会越耗时。|
122
122
| Rule Files| 加密规则文件列表。可以为0到多个。如果为空会对所有常量进行混淆。详细配置规则见[ 常量混淆] ( ./const-encryption ) 。|
123
123
124
+ ### Remove Const Field Settings
125
+
126
+ 移除const常量字段相关设置。支持通过规则文件精细地控制要保留哪些const字段。补充文档见[ 移除常量字段] ( ./remove-const-field ) 。
127
+
128
+ | 选项| 描述|
129
+ | -| -|
130
+ | Rule Files| 加密规则文件列表。可以为0到多个。如果为空会对所有常量进行混淆。详细配置规则见[ 移除常量字段] ( ./remove-const-field ) 。|
131
+
124
132
### Eval Stack Obfus Settings
125
133
126
134
执行栈的混淆设置。支持通过规则文件非常精细地控制范围和加密效果。补充文档见[ 执行栈混淆] ( ./eval-stack-obfuscation ) 。
Original file line number Diff line number Diff line change @@ -78,8 +78,8 @@ class A
78
78
<obfuz >
79
79
<assembly name =" Obfus1" >
80
80
<type name =" *" >
81
- <field name =" a" encrypt = " 1 " />
82
- <field name =" a " encrypt = " 0 " />
81
+ <field name =" a" />
82
+ <field name =" b " />
83
83
</type >
84
84
</assembly >
85
85
</obfuz >
@@ -108,5 +108,4 @@ assembly的子元素只能为type。
108
108
109
109
| 属性| 可空| 默认值| 描述|
110
110
| -| -| -| -|
111
- | name| 否|| 类型名的通配字符串,如果为空表示匹配所有类型|
112
- | encrypt| 是| 0| 是否加密此字段|
111
+ | name| 否|| 被加密的字段名。字段名的通配字符串,如果为空表示匹配所有类型|
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ Obfuz的混淆(或加密)流程的执行方式为先判定对目标是否启
22
22
23
23
- Symbol Obfuscation(符号混淆)
24
24
- Const Encryption(常量加密)
25
+ - Remove Const Field (移除const常量字段)
25
26
- Eval Stack Obfusaction (局部与临时变量混淆)
26
27
- Expr Obfusaction (表达式混淆)
27
28
- Field Encryption(字段加密)
@@ -32,8 +33,6 @@ Obfuz的混淆(或加密)流程的执行方式为先判定对目标是否启
32
33
33
34
后续将会支持的Obfuscation Pass有:
34
35
35
- - Expression Obfusaction(表达式混淆)
36
- - ControlFlow Obfuscation(控制流混淆)
37
36
- 加水印
38
37
- Anti-Debugger、Anti-Damper、Anti-Dumping
39
38
@@ -100,7 +99,7 @@ enable与disable属性用于设置当前规则中开启或者禁用哪些Pass。
100
99
101
100
- 如果值以` + ` 开关,则表示是在父节点上启用的pass上进行增量修改。
102
101
- 如果没有以` + ` 开启,则表示在` ObfuscationPassSettings.EnabledPasses ` 的值的基础上启用或者禁用某些Pass。
103
- - PASS_NAME的取值可以为` ConstEncrypt、FieldEncrypt、SymbolObfus、CallObfus、ExprObfus、ControlFlowObfus、EvalStackObfus ` 等Pass类型。详见` Obfuz.ObfusPasses.ObfuscationPassType ` 类定义。
102
+ - PASS_NAME的取值可以为` ConstEncrypt、RemoveConstField、 FieldEncrypt、SymbolObfus、CallObfus、ExprObfus、ControlFlowObfus、EvalStackObfus ` 等Pass类型。详见` Obfuz.ObfusPasses.ObfuscationPassType ` 类定义。
104
103
105
104
例如,假设EnabledPass=` SymbolObfus|ConstEncrypt|FieldEncrypt ` ,使用以下配置。
106
105
Original file line number Diff line number Diff line change
1
+ # 移除常量字段
2
+
3
+ const常量字段大多数情况下只在源码中有意义,编译为dll时会inline对常量字段的访问,即编译后的代码并不会引用const字段。
4
+ 因此移除const字段并不会引发代码错误,除非需要反射访问该字段。
5
+
6
+ 移除const字段可以减少混淆后的代码的有效信息,因此混淆时默认会移除这些字段。
7
+
8
+ ## 设置
9
+
10
+ ` ObfuzSettings.RemoveConstFieldSettings ` 中包含相关设置,详细见文档[ 设置] ( ./configuration ) 。
11
+
12
+ ## ` [ObfuzIgnore] `
13
+
14
+ 被` [ObfuzIgnore(ObfuzScope.Field)] ` 影响的常量字段不会被移除。
15
+
16
+ 例如下面的ConstEncryptTestClass类的removedField会被移除,而preservedField和preservedField2字段都会被保留。
17
+
18
+ ``` csharp
19
+ class ConstEncryptTestClass
20
+ {
21
+ // This const field should be removed by the obfuscator.
22
+ public const int removedField = 1 ;
23
+
24
+ [ObfuzIgnore (ObfuzScope .Field )]
25
+ public const int preservedField = 2 ;
26
+
27
+ [ObfuzIgnore ]
28
+ public const int preservedField2 = 2 ;
29
+ }
30
+ ```
31
+
32
+ ## 规则文件
33
+
34
+ 支持通过规则文件精细地控制保留哪些常量字段。` RemoveConstFieldSettings.RuleFiles ` 选项中可以配置0-N个规则文件。
35
+ 规则文件的相对路径为项目目录,有效的规则文件路径类似这样:` Assets/XXX/YYY.xml ` 。
36
+
37
+ 出现在规则文件中的字段** 不会被移除** 。
38
+
39
+ 配置示例如下:
40
+
41
+ ``` xml
42
+
43
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
44
+
45
+ <obfuz >
46
+ <assembly name =" Obfus1" >
47
+ <type name =" Tests.RemoveConstField.ConstEncryptTestClass" >
48
+ <field name =" preservedField2" />
49
+ </type >
50
+ </assembly >
51
+ </obfuz >
52
+ ```
53
+
54
+ - 顶层tag必须是obfuz
55
+ - 次级tag必须是assembly
56
+
57
+ ### assembly
58
+
59
+ | 属性| 可空| 默认值| 描述|
60
+ | -| -| -| -|
61
+ | name| 否|| 程序集名,必须在混淆程序集列表中|
62
+
63
+ assembly的子元素只能为type。
64
+
65
+ ### type
66
+
67
+ | 属性| 可空| 默认值| 描述|
68
+ | -| -| -| -|
69
+ | name| 否|| 类型名的通配字符串,如果为空表示匹配所有类型。嵌套类型使用` / ` 划分声明所在类型和被包围的子类型,如` test.ClassA/ClassB ` 。|
70
+
71
+ 由于字段加密只能作用于字段,因此type的子元素只能为field。
72
+
73
+ ### field
74
+
75
+ | 属性| 可空| 默认值| 描述|
76
+ | -| -| -| -|
77
+ | name| 否|| 要保留的常量字段名。字段名的通配字符串,如果为空表示匹配所有类型。|
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ const sidebars: SidebarsConfig = {
59
59
'manual/obfuscation-instincts' ,
60
60
'manual/symbol-obfuscation' ,
61
61
'manual/const-encryption' ,
62
+ 'manual/remove-const-field' ,
62
63
'manual/field-encryption' ,
63
64
'manual/eval-stack-obfuscation' ,
64
65
'manual/expr-obfuscation' ,
You can’t perform that action at this time.
0 commit comments