1use serde::{Deserialize, Serialize};
8
9pub const YAML_CONFIG_VERSION: &str = "1.0.1";
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(Debug, Serialize, Deserialize)]
84pub struct FakePdbString {
85 pub enabled: bool,
87 pub value: String,
89}
90
91#[derive(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 pub ida_crasher: bool,
105 pub import_protection: bool,
107 pub obscure_entry_point: bool,
109 pub clear_unwind_info: bool,
112 pub fake_pdb_string: FakePdbString,
114 pub custom_section_name: CustomSectionName,
116}
117
118#[derive(Debug, Serialize, Deserialize, Clone)]
120pub struct Semantics {
121 pub add: bool,
122 pub sub: bool,
123 pub and: bool,
124 pub xor: bool,
125 pub or: bool,
126 pub not: bool,
127 pub neg: bool,
128}
129
130#[derive(Debug, Serialize, Deserialize, Clone)]
132pub struct BitWidths {
133 pub bit8: bool,
134 pub bit16: bool,
135 pub bit32: bool,
136 pub bit64: bool,
137}
138
139#[derive(Debug, Serialize, Deserialize, Clone)]
141pub struct LoopEncodeSemantics {
142 pub iterations: u32,
144 pub probability: u32,
146 pub semantics: Semantics,
148 pub bitwidths: BitWidths,
150}
151
152#[derive(Debug, Serialize, Deserialize, Clone)]
154pub struct MixedBooleanArithmetic {
155 pub iterations: u32,
156 pub probability: u32,
157 pub semantics: Semantics,
158 pub bitwidths: BitWidths,
159}
160
161#[derive(Debug, Serialize, Deserialize, Clone)]
163pub struct MutationEngine {
164 pub iterations: u32,
165 pub probability: u32,
166 pub extension: MutationEngineExtension,
167 pub semantics: Semantics,
168 pub bitwidths: BitWidths,
169}
170
171#[derive(Debug, Serialize, Deserialize, Clone)]
173pub struct IDADecompilerCrasher;
174
175#[derive(Debug, Serialize, Deserialize, Clone)]
177pub struct ObscureConstants;
178
179#[derive(Debug, Serialize, Deserialize, Clone)]
181pub struct ObscureReferences;
182
183#[derive(Debug, Serialize, Deserialize, Clone)]
185pub struct ObscureControlFlow;
186
187#[derive(Debug, Serialize, Deserialize, Clone)]
189#[serde(tag = "type")]
190pub enum ObfuscationPass {
191 LoopEncodeSemantics(LoopEncodeSemantics),
192 MixedBooleanArithmetic(MixedBooleanArithmetic),
193 MutationEngine(MutationEngine),
194 IDADecompilerCrasher,
195 ObscureConstants,
196 ObscureReferences,
197 ObscureControlFlow,
198}
199
200#[derive(Debug, Serialize, Deserialize)]
202pub struct CDProfile {
203 pub name: String,
205 pub passes: Vec<ObfuscationPass>,
207 pub compiler_settings: CDCompilerSettings,
209 pub symbols: Vec<u64>,
211}
212
213#[derive(Debug, Serialize, Deserialize)]
215pub struct CDConfig {
216 pub module_settings: CDModuleSettings,
218 pub profiles: Vec<CDProfile>,
220}
221
222#[derive(Deserialize, Serialize, Clone, Debug)]
224pub struct AnalysisFunction {
225 pub rva: u64,
227 pub symbol: String,
229 pub ref_count: usize,
231}
232
233#[derive(Deserialize, Serialize, Clone, Debug)]
235pub struct AnalysisReject {
236 pub rva: u64,
238 pub symbol: String,
240 pub ty: String,
242 pub reason: String,
244}
245
246#[derive(Deserialize, Serialize, Clone, Debug)]
248pub struct AnalysisMacroProfile {
249 pub name: String,
251 pub rvas: Vec<u64>,
253}
254
255#[derive(Deserialize, Serialize, Clone, Debug)]
257pub struct AnalysisResult {
258 pub environment: PeEnvironment,
260 pub functions: Vec<AnalysisFunction>,
262 pub rejects: Vec<AnalysisReject>,
264 pub macros: Vec<AnalysisMacroProfile>,
266}
267
268#[derive(Debug, Serialize, Deserialize)]
270pub enum YamlSymbol {
271 Name(String),
273 Rva(u64),
275}
276
277#[derive(Debug, Serialize, Deserialize)]
279pub struct YamlProfile {
280 pub name: String,
282 pub passes: Vec<ObfuscationPass>,
284 pub compiler_settings: CDCompilerSettings,
286 pub symbols: Vec<YamlSymbol>,
288 pub color: Option<String>,
290}
291
292#[derive(Debug, Serialize, Deserialize)]
294pub struct YamlConfig {
295 pub version: String,
297 pub module_settings: CDModuleSettings,
299 pub profiles: Vec<YamlProfile>,
301}