1use serde::{Deserialize, Serialize};
8
9pub const YAML_CONFIG_VERSION: &str = "1.0.4";
11
12#[derive(Debug, Serialize, Deserialize, Clone)]
14pub enum MutationEngineExtension {
15 Generic,
17 SSE3,
19 SSE42
21}
22
23#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
25pub enum PeEnvironment {
26 UserMode,
28 KernelMode,
30 UEFI,
32}
33
34#[derive(Debug, Serialize, Deserialize, Clone)]
36pub struct LifterSettings {
37 pub lift_calls: bool,
39 pub calling_convention: String,
41 pub max_stack_copy_size: u32,
43 pub split_on_calls_fallback: bool,
45}
46
47#[derive(Debug, Serialize, Deserialize, Clone)]
49pub struct OptimizationSettings {
50 pub constant_propagation: bool,
52 pub instruction_combine: bool,
54 pub dead_code_elim: bool,
56 pub prune_useless_block_params: bool,
58 pub iterations: u32,
60}
61
62#[derive(Debug, Serialize, Deserialize, Clone)]
64pub struct AssemblerSettings {
65 pub shuffle_basic_blocks: bool,
67 pub instruction_prefix: String,
69 pub random_prefix_chance: f64,
71}
72
73#[derive(Debug, Serialize, Deserialize, Clone)]
75pub struct CDCompilerSettings {
76 pub assembler_settings: AssemblerSettings,
78 pub optimization_settings: OptimizationSettings,
80 pub lifter_settings: LifterSettings,
82}
83
84#[derive(Default, Debug, Serialize, Deserialize)]
86pub struct FakePdbString {
87 pub enabled: bool,
89 pub value: String,
91}
92
93#[derive(Default, Debug, Serialize, Deserialize)]
95pub struct CustomSectionName {
96 pub enabled: bool,
98 pub value: String,
100}
101
102#[derive(Debug, Serialize, Deserialize)]
104pub struct CDModuleSettings {
105 #[serde(default)]
107 pub ida_crasher: bool,
108 #[serde(default)]
110 pub import_protection: bool,
111 #[serde(default)]
113 pub pack_output_file: bool,
114 #[serde(default)]
116 pub obscure_entry_point: bool,
117 #[serde(default)]
120 pub clear_unwind_info: bool,
121 #[serde(default)]
123 pub fake_pdb_string: FakePdbString,
124 #[serde(default)]
126 pub custom_section_name: CustomSectionName,
127}
128
129#[derive(Debug, Serialize, Deserialize, Clone)]
131pub struct Semantics {
132 #[serde(default)]
133 pub add: bool,
134 #[serde(default)]
135 pub sub: bool,
136 #[serde(default)]
137 pub and: bool,
138 #[serde(default)]
139 pub xor: bool,
140 #[serde(default)]
141 pub or: bool,
142 #[serde(default)]
143 pub not: bool,
144 #[serde(default)]
145 pub neg: bool,
146}
147
148#[derive(Debug, Serialize, Deserialize, Clone)]
150pub struct BitWidths {
151 #[serde(default)]
152 pub bit8: bool,
153 #[serde(default)]
154 pub bit16: bool,
155 #[serde(default)]
156 pub bit32: bool,
157 #[serde(default)]
158 pub bit64: bool,
159}
160
161#[derive(Debug, Serialize, Deserialize, Clone)]
165pub struct SsaOrigins {
166 pub normal: bool,
167 pub memop: bool,
168 pub fp_based_memop: bool,
169 pub sp_based_memop: bool,
170}
171
172#[derive(Debug, Serialize, Deserialize, Clone)]
174pub struct LoopEncodeSemantics {
175 pub iterations: u32,
177 pub probability: u32,
179 pub semantics: Semantics,
181 pub bitwidths: BitWidths,
183 pub ethnicities: SsaOrigins,
184}
185
186#[derive(Debug, Serialize, Deserialize, Clone)]
188pub struct MixedBooleanArithmetic {
189 pub iterations: u32,
190 pub probability: u32,
191 pub semantics: Semantics,
192 pub bitwidths: BitWidths,
193 pub ethnicities: SsaOrigins,
194}
195
196#[derive(Debug, Serialize, Deserialize, Clone)]
198pub struct MutationEngine {
199 pub iterations: u32,
200 pub probability: u32,
201 pub extension: MutationEngineExtension,
202 pub semantics: Semantics,
203 pub bitwidths: BitWidths,
204 pub ethnicities: SsaOrigins,
205}
206
207#[derive(Debug, Serialize, Deserialize, Clone)]
209pub struct IDADecompilerCrasher;
210
211#[derive(Debug, Serialize, Deserialize, Clone)]
213pub struct SuppressConstants {
214 pub ethnicities: SsaOrigins,
215}
216
217#[derive(Debug, Serialize, Deserialize, Clone)]
220pub struct ObscureConstants {
221 pub probability: u32,
222 pub iterations: u32,
223 pub bitwidths: BitWidths,
224 pub ethnicities: SsaOrigins,
225}
226
227#[derive(Debug, Serialize, Deserialize, Clone)]
229pub struct ObscureReferences;
230
231#[derive(Debug, Serialize, Deserialize, Clone)]
233pub struct ObscureControlFlow {
234 pub probability: u32,
235}
236
237#[derive(Debug, Serialize, Deserialize, Clone)]
239pub struct TetherExtraction {
240 pub min_extract_len: usize,
243 pub endpoint: String,
245 pub port: u16,
247 pub server_public_key: String,
250}
251
252#[derive(Debug, Serialize, Deserialize, Clone)]
254pub struct OpaqueBlockDuplication {
255 pub iterations: u32,
257 pub probability: u32,
259}
260
261#[derive(Debug, Serialize, Deserialize, Clone)]
263pub struct SplitBlockPass {
264 pub threshold: u32,
266}
267
268#[derive(Debug, Serialize, Deserialize, Clone)]
270pub struct LeaEncodeImm {
271 pub probability: u32,
273 pub ethnicities: SsaOrigins,
274}
275
276#[derive(Debug, Serialize, Deserialize, Clone)]
278#[serde(tag = "type")]
279pub enum ObfuscationPass {
280 LoopEncodeSemantics(LoopEncodeSemantics),
281 MixedBooleanArithmetic(MixedBooleanArithmetic),
282 MutationEngine(MutationEngine),
283 TetherExtraction(TetherExtraction),
284 SplitBlockPass(SplitBlockPass),
285 OpaqueBlockDuplication(OpaqueBlockDuplication),
286 ObscureControlFlow(ObscureControlFlow),
287 LeaEncodeImm(LeaEncodeImm),
288 ObscureConstants(ObscureConstants),
289 SuppressConstants(SuppressConstants),
290 IDADecompilerCrasher,
291 ObscureReferences,
292 AntiEmulator,
293}
294
295#[derive(Debug, Serialize, Deserialize)]
297pub struct CDProfile {
298 pub name: String,
300 pub passes: Vec<ObfuscationPass>,
302 pub compiler_settings: CDCompilerSettings,
304 pub symbols: Vec<u64>,
306}
307
308#[derive(Debug, Serialize, Deserialize)]
310pub struct CDConfig {
311 pub module_settings: CDModuleSettings,
313 pub profiles: Vec<CDProfile>,
315}
316
317#[derive(Deserialize, Serialize, Clone, Debug)]
319pub struct AnalysisFunction {
320 pub rva: u64,
322 pub symbol: String,
324 pub ref_count: usize,
326}
327
328#[derive(Deserialize, Serialize, Clone, Debug)]
330pub struct AnalysisReject {
331 pub rva: u64,
333 pub symbol: String,
335 pub ty: String,
337 pub reason: String,
339}
340
341#[derive(Deserialize, Serialize, Clone, Debug)]
343pub struct AnalysisMacroProfile {
344 pub name: String,
346 pub rvas: Vec<u64>,
348}
349
350#[derive(Deserialize, Serialize, Clone, Debug)]
352pub struct AnalysisResult {
353 pub environment: PeEnvironment,
355 pub functions: Vec<AnalysisFunction>,
357 pub rejects: Vec<AnalysisReject>,
359 pub macros: Vec<AnalysisMacroProfile>,
361}
362
363#[derive(Debug, Serialize, Deserialize)]
365pub enum YamlSymbol {
366 Name(String),
368 Rva(u64),
370}
371
372#[derive(Debug, Serialize, Deserialize)]
374pub struct YamlProfile {
375 pub name: String,
377 pub passes: Vec<ObfuscationPass>,
379 pub compiler_settings: CDCompilerSettings,
381 pub symbols: Vec<YamlSymbol>,
383 pub color: Option<String>,
385}
386
387#[derive(Debug, Serialize, Deserialize)]
389pub struct YamlConfig {
390 pub version: String,
392 pub module_settings: CDModuleSettings,
394 pub profiles: Vec<YamlProfile>,
396}