1use serde::{Deserialize, Serialize};
8
9pub const YAML_CONFIG_VERSION: &str = "1.0.2";
11
12#[derive(Debug, Serialize, Deserialize, Clone)]
14pub enum MutationEngineExtension {
15 Generic,
17 SSE,
19}
20
21#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
23pub enum PeEnvironment {
24 UserMode,
26 KernelMode,
28 UEFI,
30}
31
32#[derive(Debug, Serialize, Deserialize, Clone)]
34pub struct LifterSettings {
35 pub lift_calls: bool,
37 pub calling_convention: String,
39 pub max_stack_copy_size: u32,
41 pub split_on_calls_fallback: bool,
43}
44
45#[derive(Debug, Serialize, Deserialize, Clone)]
47pub struct OptimizationSettings {
48 pub constant_propagation: bool,
50 pub instruction_combine: bool,
52 pub dead_code_elim: bool,
54 pub prune_useless_block_params: bool,
56 pub iterations: u32,
58}
59
60#[derive(Debug, Serialize, Deserialize, Clone)]
62pub struct AssemblerSettings {
63 pub shuffle_basic_blocks: bool,
65 pub instruction_prefix: String,
67 pub random_prefix_chance: f64,
69}
70
71#[derive(Debug, Serialize, Deserialize, Clone)]
73pub struct CDCompilerSettings {
74 pub assembler_settings: AssemblerSettings,
76 pub optimization_settings: OptimizationSettings,
78 pub lifter_settings: LifterSettings,
80}
81
82#[derive(Default, Debug, Serialize, Deserialize)]
84pub struct FakePdbString {
85 pub enabled: bool,
87 pub value: String,
89}
90
91#[derive(Default, Debug, Serialize, Deserialize)]
93pub struct CustomSectionName {
94 pub enabled: bool,
96 pub value: String,
98}
99
100#[derive(Debug, Serialize, Deserialize)]
102pub struct CDModuleSettings {
103 #[serde(default)]
105 pub ida_crasher: bool,
106 #[serde(default)]
108 pub import_protection: bool,
109 #[serde(default)]
111 pub obscure_entry_point: bool,
112 #[serde(default)]
115 pub clear_unwind_info: bool,
116 #[serde(default)]
118 pub fake_pdb_string: FakePdbString,
119 #[serde(default)]
121 pub custom_section_name: CustomSectionName,
122}
123
124#[derive(Debug, Serialize, Deserialize, Clone)]
126pub struct Semantics {
127 #[serde(default)]
128 pub add: bool,
129 #[serde(default)]
130 pub sub: bool,
131 #[serde(default)]
132 pub and: bool,
133 #[serde(default)]
134 pub xor: bool,
135 #[serde(default)]
136 pub or: bool,
137 #[serde(default)]
138 pub not: bool,
139 #[serde(default)]
140 pub neg: bool,
141}
142
143#[derive(Debug, Serialize, Deserialize, Clone)]
145pub struct BitWidths {
146 #[serde(default)]
147 pub bit8: bool,
148 #[serde(default)]
149 pub bit16: bool,
150 #[serde(default)]
151 pub bit32: bool,
152 #[serde(default)]
153 pub bit64: bool,
154}
155
156#[derive(Debug, Serialize, Deserialize, Clone)]
158pub struct LoopEncodeSemantics {
159 pub iterations: u32,
161 pub probability: u32,
163 pub semantics: Semantics,
165 pub bitwidths: BitWidths,
167}
168
169#[derive(Debug, Serialize, Deserialize, Clone)]
171pub struct MixedBooleanArithmetic {
172 pub iterations: u32,
173 pub probability: u32,
174 pub semantics: Semantics,
175 pub bitwidths: BitWidths,
176}
177
178#[derive(Debug, Serialize, Deserialize, Clone)]
180pub struct MutationEngine {
181 pub iterations: u32,
182 pub probability: u32,
183 pub extension: MutationEngineExtension,
184 pub semantics: Semantics,
185 pub bitwidths: BitWidths,
186}
187
188#[derive(Debug, Serialize, Deserialize, Clone)]
190pub struct IDADecompilerCrasher;
191
192#[derive(Debug, Serialize, Deserialize, Clone)]
194pub struct ObscureConstants;
195
196#[derive(Debug, Serialize, Deserialize, Clone)]
198pub struct ObscureReferences;
199
200#[derive(Debug, Serialize, Deserialize, Clone)]
202pub struct ObscureControlFlow {
203 pub probability: u32,
204}
205
206#[derive(Debug, Serialize, Deserialize, Clone)]
208pub struct TetherExtraction {
209 pub min_extract_len: usize,
212 pub endpoint: String,
214 pub port: u16,
216 pub server_public_key: String,
219}
220
221#[derive(Debug, Serialize, Deserialize, Clone)]
223#[serde(tag = "type")]
224pub enum ObfuscationPass {
225 LoopEncodeSemantics(LoopEncodeSemantics),
226 MixedBooleanArithmetic(MixedBooleanArithmetic),
227 MutationEngine(MutationEngine),
228 TetherExtraction(TetherExtraction),
229 IDADecompilerCrasher,
230 ObscureConstants,
231 ObscureReferences,
232 ObscureControlFlow,
233}
234
235#[derive(Debug, Serialize, Deserialize)]
237pub struct CDProfile {
238 pub name: String,
240 pub passes: Vec<ObfuscationPass>,
242 pub compiler_settings: CDCompilerSettings,
244 pub symbols: Vec<u64>,
246}
247
248#[derive(Debug, Serialize, Deserialize)]
250pub struct CDConfig {
251 pub module_settings: CDModuleSettings,
253 pub profiles: Vec<CDProfile>,
255}
256
257#[derive(Deserialize, Serialize, Clone, Debug)]
259pub struct AnalysisFunction {
260 pub rva: u64,
262 pub symbol: String,
264 pub ref_count: usize,
266}
267
268#[derive(Deserialize, Serialize, Clone, Debug)]
270pub struct AnalysisReject {
271 pub rva: u64,
273 pub symbol: String,
275 pub ty: String,
277 pub reason: String,
279}
280
281#[derive(Deserialize, Serialize, Clone, Debug)]
283pub struct AnalysisMacroProfile {
284 pub name: String,
286 pub rvas: Vec<u64>,
288}
289
290#[derive(Deserialize, Serialize, Clone, Debug)]
292pub struct AnalysisResult {
293 pub environment: PeEnvironment,
295 pub functions: Vec<AnalysisFunction>,
297 pub rejects: Vec<AnalysisReject>,
299 pub macros: Vec<AnalysisMacroProfile>,
301}
302
303#[derive(Debug, Serialize, Deserialize)]
305pub enum YamlSymbol {
306 Name(String),
308 Rva(u64),
310}
311
312#[derive(Debug, Serialize, Deserialize)]
314pub struct YamlProfile {
315 pub name: String,
317 pub passes: Vec<ObfuscationPass>,
319 pub compiler_settings: CDCompilerSettings,
321 pub symbols: Vec<YamlSymbol>,
323 pub color: Option<String>,
325}
326
327#[derive(Debug, Serialize, Deserialize)]
329pub struct YamlConfig {
330 pub version: String,
332 pub module_settings: CDModuleSettings,
334 pub profiles: Vec<YamlProfile>,
336}