1use serde::{Deserialize, Serialize};
8
9pub const YAML_CONFIG_VERSION: &str = "1.0.3";
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)]
223pub struct OpaqueBlockDuplication {
224 pub iterations: u32,
226 pub probability: u32,
228}
229
230#[derive(Debug, Serialize, Deserialize, Clone)]
232#[serde(tag = "type")]
233pub enum ObfuscationPass {
234 LoopEncodeSemantics(LoopEncodeSemantics),
235 MixedBooleanArithmetic(MixedBooleanArithmetic),
236 MutationEngine(MutationEngine),
237 TetherExtraction(TetherExtraction),
238 IDADecompilerCrasher,
239 ObscureConstants,
240 ObscureReferences,
241 AntiEmulator,
242 OpaqueBlockDuplication(OpaqueBlockDuplication),
243 ObscureControlFlow(ObscureControlFlow),
244}
245
246#[derive(Debug, Serialize, Deserialize)]
248pub struct CDProfile {
249 pub name: String,
251 pub passes: Vec<ObfuscationPass>,
253 pub compiler_settings: CDCompilerSettings,
255 pub symbols: Vec<u64>,
257}
258
259#[derive(Debug, Serialize, Deserialize)]
261pub struct CDConfig {
262 pub module_settings: CDModuleSettings,
264 pub profiles: Vec<CDProfile>,
266}
267
268#[derive(Deserialize, Serialize, Clone, Debug)]
270pub struct AnalysisFunction {
271 pub rva: u64,
273 pub symbol: String,
275 pub ref_count: usize,
277}
278
279#[derive(Deserialize, Serialize, Clone, Debug)]
281pub struct AnalysisReject {
282 pub rva: u64,
284 pub symbol: String,
286 pub ty: String,
288 pub reason: String,
290}
291
292#[derive(Deserialize, Serialize, Clone, Debug)]
294pub struct AnalysisMacroProfile {
295 pub name: String,
297 pub rvas: Vec<u64>,
299}
300
301#[derive(Deserialize, Serialize, Clone, Debug)]
303pub struct AnalysisResult {
304 pub environment: PeEnvironment,
306 pub functions: Vec<AnalysisFunction>,
308 pub rejects: Vec<AnalysisReject>,
310 pub macros: Vec<AnalysisMacroProfile>,
312}
313
314#[derive(Debug, Serialize, Deserialize)]
316pub enum YamlSymbol {
317 Name(String),
319 Rva(u64),
321}
322
323#[derive(Debug, Serialize, Deserialize)]
325pub struct YamlProfile {
326 pub name: String,
328 pub passes: Vec<ObfuscationPass>,
330 pub compiler_settings: CDCompilerSettings,
332 pub symbols: Vec<YamlSymbol>,
334 pub color: Option<String>,
336}
337
338#[derive(Debug, Serialize, Deserialize)]
340pub struct YamlConfig {
341 pub version: String,
343 pub module_settings: CDModuleSettings,
345 pub profiles: Vec<YamlProfile>,
347}