1use serde::{Deserialize, Serialize};
8use std::path::PathBuf;
9
10pub const YAML_CONFIG_VERSION: &str = "1.0.0";
12
13#[derive(Debug, Serialize, Deserialize, Clone)]
15pub enum MutationEngineExtension {
16 Generic = 0,
18 SSE = 1,
20}
21
22#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
24pub enum PeEnvironment {
25 UserMode,
27 KernelMode,
29 UEFI,
31}
32
33#[derive(Debug, Serialize, Deserialize, Clone)]
35pub struct LifterSettings {
36 pub lift_calls: bool,
38 pub max_stack_copy_size: u32,
40 pub split_on_calls_fallback: bool,
42}
43
44#[derive(Debug, Serialize, Deserialize, Clone)]
46pub struct OptimizationSettings {
47 pub constant_propagation: bool,
49 pub instruction_combine: bool,
51 pub dead_code_elim: bool,
53 pub prune_useless_block_params: bool,
55 pub iterations: u32,
57}
58
59#[derive(Debug, Serialize, Deserialize, Clone)]
61pub struct AssemblerSettings {
62 pub shuffle_basic_blocks: bool,
64 pub instruction_prefix: String,
66 pub random_prefix_chance: f64,
68}
69
70#[derive(Debug, Serialize, Deserialize, Clone)]
72pub struct CDCompilerSettings {
73 pub assembler_settings: AssemblerSettings,
75 pub optimization_settings: OptimizationSettings,
77 pub lifter_settings: LifterSettings,
79}
80
81#[derive(Debug, Serialize, Deserialize)]
83pub struct FakePdbString {
84 pub enabled: bool,
86 pub value: String,
88}
89
90#[derive(Debug, Serialize, Deserialize)]
92pub struct CustomSectionName {
93 pub enabled: bool,
95 pub value: String,
97}
98
99#[derive(Debug, Serialize, Deserialize)]
101pub struct CDModuleSettings {
102 pub ida_crasher: bool,
104 pub import_protection: bool,
106 pub fake_pdb_string: FakePdbString,
108 pub custom_section_name: CustomSectionName,
110}
111
112#[derive(Debug, Serialize, Deserialize, Clone)]
114pub struct Semantics {
115 pub add: bool,
116 pub sub: bool,
117 pub and: bool,
118 pub xor: bool,
119 pub or: bool,
120 pub not: bool,
121 pub neg: bool,
122}
123
124#[derive(Debug, Serialize, Deserialize, Clone)]
126pub struct BitWidths {
127 pub bit8: bool,
128 pub bit16: bool,
129 pub bit32: bool,
130 pub bit64: bool,
131}
132
133#[derive(Debug, Serialize, Deserialize, Clone)]
135pub struct LoopEncodeSemantics {
136 pub iterations: u32,
138 pub probability: u32,
140 pub semantics: Semantics,
142 pub bitwidths: BitWidths,
144}
145
146#[derive(Debug, Serialize, Deserialize, Clone)]
148pub struct MixedBooleanArithmetic {
149 pub iterations: u32,
150 pub probability: u32,
151 pub semantics: Semantics,
152 pub bitwidths: BitWidths,
153}
154
155#[derive(Debug, Serialize, Deserialize, Clone)]
157pub struct MutationEngine {
158 pub iterations: u32,
159 pub probability: u32,
160 pub extension: MutationEngineExtension,
161 pub semantics: Semantics,
162 pub bitwidths: BitWidths,
163}
164
165#[derive(Debug, Serialize, Deserialize, Clone)]
167pub struct IDADecompilerCrasher;
168
169#[derive(Debug, Serialize, Deserialize, Clone)]
171pub struct ObscureConstants;
172
173#[derive(Debug, Serialize, Deserialize, Clone)]
175pub struct ObscureReferences;
176
177#[derive(Debug, Serialize, Deserialize, Clone)]
179pub struct ObscureControlFlow;
180
181#[derive(Debug, Serialize, Deserialize, Clone)]
183pub enum ObfuscationPass {
184 LoopEncodeSemantics(LoopEncodeSemantics),
185 MixedBooleanArithmetic(MixedBooleanArithmetic),
186 MutationEngine(MutationEngine),
187 IDADecompilerCrasher(IDADecompilerCrasher),
188 ObscureConstants(ObscureConstants),
189 ObscureReferences(ObscureReferences),
190 ObscureControlFlow(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: String,
283}
284
285#[derive(Debug, Serialize, Deserialize)]
287pub struct YamlConfig {
288 pub version: String,
290 pub api_key: String,
292 pub timeout: u64,
295 pub input_file: PathBuf,
297 pub output_file: PathBuf,
299 pub pdb_file: Option<PathBuf>,
301 pub module_settings: CDModuleSettings,
303 pub profiles: Vec<YamlProfile>,
305}