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(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
204#[derive(Debug, Serialize, Deserialize, Clone)]
206pub struct TetherExtraction {
207 pub min_extract_len: usize,
210 pub endpoint: String,
212 pub port: u16,
214 pub server_public_key: String,
217}
218
219#[derive(Debug, Serialize, Deserialize, Clone)]
221#[serde(tag = "type")]
222pub enum ObfuscationPass {
223 LoopEncodeSemantics(LoopEncodeSemantics),
224 MixedBooleanArithmetic(MixedBooleanArithmetic),
225 MutationEngine(MutationEngine),
226 TetherExtraction(TetherExtraction),
227 IDADecompilerCrasher,
228 ObscureConstants,
229 ObscureReferences,
230 ObscureControlFlow,
231}
232
233#[derive(Debug, Serialize, Deserialize)]
235pub struct CDProfile {
236 pub name: String,
238 pub passes: Vec<ObfuscationPass>,
240 pub compiler_settings: CDCompilerSettings,
242 pub symbols: Vec<u64>,
244}
245
246#[derive(Debug, Serialize, Deserialize)]
248pub struct CDConfig {
249 pub module_settings: CDModuleSettings,
251 pub profiles: Vec<CDProfile>,
253}
254
255#[derive(Deserialize, Serialize, Clone, Debug)]
257pub struct AnalysisFunction {
258 pub rva: u64,
260 pub symbol: String,
262 pub ref_count: usize,
264}
265
266#[derive(Deserialize, Serialize, Clone, Debug)]
268pub struct AnalysisReject {
269 pub rva: u64,
271 pub symbol: String,
273 pub ty: String,
275 pub reason: String,
277}
278
279#[derive(Deserialize, Serialize, Clone, Debug)]
281pub struct AnalysisMacroProfile {
282 pub name: String,
284 pub rvas: Vec<u64>,
286}
287
288#[derive(Deserialize, Serialize, Clone, Debug)]
290pub struct AnalysisResult {
291 pub environment: PeEnvironment,
293 pub functions: Vec<AnalysisFunction>,
295 pub rejects: Vec<AnalysisReject>,
297 pub macros: Vec<AnalysisMacroProfile>,
299}
300
301#[derive(Debug, Serialize, Deserialize)]
303pub enum YamlSymbol {
304 Name(String),
306 Rva(u64),
308}
309
310#[derive(Debug, Serialize, Deserialize)]
312pub struct YamlProfile {
313 pub name: String,
315 pub passes: Vec<ObfuscationPass>,
317 pub compiler_settings: CDCompilerSettings,
319 pub symbols: Vec<YamlSymbol>,
321 pub color: Option<String>,
323}
324
325#[derive(Debug, Serialize, Deserialize)]
327pub struct YamlConfig {
328 pub version: String,
330 pub module_settings: CDModuleSettings,
332 pub profiles: Vec<YamlProfile>,
334}