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 obscure_entry_point: bool,
114 #[serde(default)]
117 pub clear_unwind_info: bool,
118 #[serde(default)]
120 pub fake_pdb_string: FakePdbString,
121 #[serde(default)]
123 pub custom_section_name: CustomSectionName,
124}
125
126#[derive(Debug, Serialize, Deserialize, Clone)]
128pub struct Semantics {
129 #[serde(default)]
130 pub add: bool,
131 #[serde(default)]
132 pub sub: bool,
133 #[serde(default)]
134 pub and: bool,
135 #[serde(default)]
136 pub xor: bool,
137 #[serde(default)]
138 pub or: bool,
139 #[serde(default)]
140 pub not: bool,
141 #[serde(default)]
142 pub neg: bool,
143}
144
145#[derive(Debug, Serialize, Deserialize, Clone)]
147pub struct BitWidths {
148 #[serde(default)]
149 pub bit8: bool,
150 #[serde(default)]
151 pub bit16: bool,
152 #[serde(default)]
153 pub bit32: bool,
154 #[serde(default)]
155 pub bit64: bool,
156}
157
158#[derive(Debug, Serialize, Deserialize, Clone)]
162pub struct SsaOrigins {
163 pub normal: bool,
164 pub memop: bool,
165 pub fp_based_memop: bool,
166 pub sp_based_memop: bool,
167}
168
169#[derive(Debug, Serialize, Deserialize, Clone)]
171pub struct LoopEncodeSemantics {
172 pub iterations: u32,
174 pub probability: u32,
176 pub semantics: Semantics,
178 pub bitwidths: BitWidths,
180 pub ethnicities: SsaOrigins,
181}
182
183#[derive(Debug, Serialize, Deserialize, Clone)]
185pub struct MixedBooleanArithmetic {
186 pub iterations: u32,
187 pub probability: u32,
188 pub semantics: Semantics,
189 pub bitwidths: BitWidths,
190 pub ethnicities: SsaOrigins,
191}
192
193#[derive(Debug, Serialize, Deserialize, Clone)]
195pub struct MutationEngine {
196 pub iterations: u32,
197 pub probability: u32,
198 pub extension: MutationEngineExtension,
199 pub semantics: Semantics,
200 pub bitwidths: BitWidths,
201 pub ethnicities: SsaOrigins,
202}
203
204#[derive(Debug, Serialize, Deserialize, Clone)]
206pub struct IDADecompilerCrasher;
207
208#[derive(Debug, Serialize, Deserialize, Clone)]
210pub struct SuppressConstants {
211 pub ethnicities: SsaOrigins,
212}
213
214#[derive(Debug, Serialize, Deserialize, Clone)]
217pub struct ObscureConstants {
218 pub probability: u32,
219 pub iterations: u32,
220 pub bitwidths: BitWidths,
221 pub ethnicities: SsaOrigins,
222}
223
224#[derive(Debug, Serialize, Deserialize, Clone)]
226pub struct ObscureReferences;
227
228#[derive(Debug, Serialize, Deserialize, Clone)]
230pub struct ObscureControlFlow {
231 pub probability: u32,
232}
233
234#[derive(Debug, Serialize, Deserialize, Clone)]
236pub struct TetherExtraction {
237 pub min_extract_len: usize,
240 pub endpoint: String,
242 pub port: u16,
244 pub server_public_key: String,
247}
248
249#[derive(Debug, Serialize, Deserialize, Clone)]
251pub struct OpaqueBlockDuplication {
252 pub iterations: u32,
254 pub probability: u32,
256}
257
258#[derive(Debug, Serialize, Deserialize, Clone)]
260pub struct SplitBlockPass {
261 pub threshold: u32,
263}
264
265#[derive(Debug, Serialize, Deserialize, Clone)]
267pub struct LeaEncodeImm {
268 pub probability: u32,
270 pub ethnicities: SsaOrigins,
271}
272
273#[derive(Debug, Serialize, Deserialize, Clone)]
275#[serde(tag = "type")]
276pub enum ObfuscationPass {
277 LoopEncodeSemantics(LoopEncodeSemantics),
278 MixedBooleanArithmetic(MixedBooleanArithmetic),
279 MutationEngine(MutationEngine),
280 TetherExtraction(TetherExtraction),
281 SplitBlockPass(SplitBlockPass),
282 OpaqueBlockDuplication(OpaqueBlockDuplication),
283 ObscureControlFlow(ObscureControlFlow),
284 LeaEncodeImm(LeaEncodeImm),
285 ObscureConstants(ObscureConstants),
286 SuppressConstants(SuppressConstants),
287 IDADecompilerCrasher,
288 ObscureReferences,
289 AntiEmulator,
290}
291
292#[derive(Debug, Serialize, Deserialize)]
294pub struct CDProfile {
295 pub name: String,
297 pub passes: Vec<ObfuscationPass>,
299 pub compiler_settings: CDCompilerSettings,
301 pub symbols: Vec<u64>,
303}
304
305#[derive(Debug, Serialize, Deserialize)]
307pub struct CDConfig {
308 pub module_settings: CDModuleSettings,
310 pub profiles: Vec<CDProfile>,
312}
313
314#[derive(Deserialize, Serialize, Clone, Debug)]
316pub struct AnalysisFunction {
317 pub rva: u64,
319 pub symbol: String,
321 pub ref_count: usize,
323}
324
325#[derive(Deserialize, Serialize, Clone, Debug)]
327pub struct AnalysisReject {
328 pub rva: u64,
330 pub symbol: String,
332 pub ty: String,
334 pub reason: String,
336}
337
338#[derive(Deserialize, Serialize, Clone, Debug)]
340pub struct AnalysisMacroProfile {
341 pub name: String,
343 pub rvas: Vec<u64>,
345}
346
347#[derive(Deserialize, Serialize, Clone, Debug)]
349pub struct AnalysisResult {
350 pub environment: PeEnvironment,
352 pub functions: Vec<AnalysisFunction>,
354 pub rejects: Vec<AnalysisReject>,
356 pub macros: Vec<AnalysisMacroProfile>,
358}
359
360#[derive(Debug, Serialize, Deserialize)]
362pub enum YamlSymbol {
363 Name(String),
365 Rva(u64),
367}
368
369#[derive(Debug, Serialize, Deserialize)]
371pub struct YamlProfile {
372 pub name: String,
374 pub passes: Vec<ObfuscationPass>,
376 pub compiler_settings: CDCompilerSettings,
378 pub symbols: Vec<YamlSymbol>,
380 pub color: Option<String>,
382}
383
384#[derive(Debug, Serialize, Deserialize)]
386pub struct YamlConfig {
387 pub version: String,
389 pub module_settings: CDModuleSettings,
391 pub profiles: Vec<YamlProfile>,
393}