1use serde::{Deserialize, Serialize};
8
9pub const YAML_CONFIG_VERSION: &str = "1.0.0";
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 max_stack_copy_size: u32,
39 pub split_on_calls_fallback: bool,
41}
42
43#[derive(Debug, Serialize, Deserialize, Clone)]
45pub struct OptimizationSettings {
46 pub constant_propagation: bool,
48 pub instruction_combine: bool,
50 pub dead_code_elim: bool,
52 pub prune_useless_block_params: bool,
54 pub iterations: u32,
56}
57
58#[derive(Debug, Serialize, Deserialize, Clone)]
60pub struct AssemblerSettings {
61 pub shuffle_basic_blocks: bool,
63 pub instruction_prefix: String,
65 pub random_prefix_chance: f64,
67}
68
69#[derive(Debug, Serialize, Deserialize, Clone)]
71pub struct CDCompilerSettings {
72 pub assembler_settings: AssemblerSettings,
74 pub optimization_settings: OptimizationSettings,
76 pub lifter_settings: LifterSettings,
78}
79
80#[derive(Debug, Serialize, Deserialize)]
82pub struct FakePdbString {
83 pub enabled: bool,
85 pub value: String,
87}
88
89#[derive(Debug, Serialize, Deserialize)]
91pub struct CustomSectionName {
92 pub enabled: bool,
94 pub value: String,
96}
97
98#[derive(Debug, Serialize, Deserialize)]
100pub struct CDModuleSettings {
101 pub ida_crasher: bool,
103 pub import_protection: bool,
105 pub fake_pdb_string: FakePdbString,
107 pub custom_section_name: CustomSectionName,
109}
110
111#[derive(Debug, Serialize, Deserialize, Clone)]
113pub struct Semantics {
114 pub add: bool,
115 pub sub: bool,
116 pub and: bool,
117 pub xor: bool,
118 pub or: bool,
119 pub not: bool,
120 pub neg: bool,
121}
122
123#[derive(Debug, Serialize, Deserialize, Clone)]
125pub struct BitWidths {
126 pub bit8: bool,
127 pub bit16: bool,
128 pub bit32: bool,
129 pub bit64: bool,
130}
131
132#[derive(Debug, Serialize, Deserialize, Clone)]
134pub struct LoopEncodeSemantics {
135 pub iterations: u32,
137 pub probability: u32,
139 pub semantics: Semantics,
141 pub bitwidths: BitWidths,
143}
144
145#[derive(Debug, Serialize, Deserialize, Clone)]
147pub struct MixedBooleanArithmetic {
148 pub iterations: u32,
149 pub probability: u32,
150 pub semantics: Semantics,
151 pub bitwidths: BitWidths,
152}
153
154#[derive(Debug, Serialize, Deserialize, Clone)]
156pub struct MutationEngine {
157 pub iterations: u32,
158 pub probability: u32,
159 pub extension: MutationEngineExtension,
160 pub semantics: Semantics,
161 pub bitwidths: BitWidths,
162}
163
164#[derive(Debug, Serialize, Deserialize, Clone)]
166pub struct IDADecompilerCrasher;
167
168#[derive(Debug, Serialize, Deserialize, Clone)]
170pub struct ObscureConstants;
171
172#[derive(Debug, Serialize, Deserialize, Clone)]
174pub struct ObscureReferences;
175
176#[derive(Debug, Serialize, Deserialize, Clone)]
178pub struct ObscureControlFlow;
179
180#[derive(Debug, Serialize, Deserialize, Clone)]
182#[serde(tag = "type")]
183pub enum ObfuscationPass {
184 LoopEncodeSemantics(LoopEncodeSemantics),
185 MixedBooleanArithmetic(MixedBooleanArithmetic),
186 MutationEngine(MutationEngine),
187 IDADecompilerCrasher,
188 ObscureConstants,
189 ObscureReferences,
190 ObscureControlFlow,
191}
192
193#[derive(Debug, Serialize, Deserialize)]
195pub struct CDProfile {
196 pub name: String,
198 pub passes: Vec<ObfuscationPass>,
200 pub compiler_settings: CDCompilerSettings,
202 pub symbols: Vec<u64>,
204}
205
206#[derive(Debug, Serialize, Deserialize)]
208pub struct CDConfig {
209 pub module_settings: CDModuleSettings,
211 pub profiles: Vec<CDProfile>,
213}
214
215#[derive(Deserialize, Serialize, Clone, Debug)]
217pub struct AnalysisFunction {
218 pub rva: u64,
220 pub symbol: String,
222 pub ref_count: usize,
224}
225
226#[derive(Deserialize, Serialize, Clone, Debug)]
228pub struct AnalysisReject {
229 pub rva: u64,
231 pub symbol: String,
233 pub ty: String,
235 pub reason: String,
237}
238
239#[derive(Deserialize, Serialize, Clone, Debug)]
241pub struct AnalysisMacroProfile {
242 pub name: String,
244 pub rvas: Vec<u64>,
246}
247
248#[derive(Deserialize, Serialize, Clone, Debug)]
250pub struct AnalysisResult {
251 pub environment: PeEnvironment,
253 pub functions: Vec<AnalysisFunction>,
255 pub rejects: Vec<AnalysisReject>,
257 pub macros: Vec<AnalysisMacroProfile>,
259}
260
261#[derive(Debug, Serialize, Deserialize)]
263pub enum YamlSymbol {
264 Name(String),
266 Rva(u64),
268}
269
270#[derive(Debug, Serialize, Deserialize)]
272pub struct YamlProfile {
273 pub name: String,
275 pub passes: Vec<ObfuscationPass>,
277 pub compiler_settings: CDCompilerSettings,
279 pub symbols: Vec<YamlSymbol>,
281 pub color: Option<String>,
283}
284
285#[derive(Debug, Serialize, Deserialize)]
287pub struct YamlConfig {
288 pub version: String,
290 pub module_settings: CDModuleSettings,
292 pub profiles: Vec<YamlProfile>,
294}