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)]
183#[serde(tag = "type")]
184pub enum ObfuscationPass {
185 LoopEncodeSemantics(LoopEncodeSemantics),
186 MixedBooleanArithmetic(MixedBooleanArithmetic),
187 MutationEngine(MutationEngine),
188 IDADecompilerCrasher,
189 ObscureConstants,
190 ObscureReferences,
191 ObscureControlFlow,
192}
193
194#[derive(Debug, Serialize, Deserialize)]
196pub struct CDProfile {
197 pub name: String,
199 pub passes: Vec<ObfuscationPass>,
201 pub compiler_settings: CDCompilerSettings,
203 pub symbols: Vec<u64>,
205}
206
207#[derive(Debug, Serialize, Deserialize)]
209pub struct CDConfig {
210 pub module_settings: CDModuleSettings,
212 pub profiles: Vec<CDProfile>,
214}
215
216#[derive(Deserialize, Serialize, Clone, Debug)]
218pub struct AnalysisFunction {
219 pub rva: u64,
221 pub symbol: String,
223 pub ref_count: usize,
225}
226
227#[derive(Deserialize, Serialize, Clone, Debug)]
229pub struct AnalysisReject {
230 pub rva: u64,
232 pub symbol: String,
234 pub ty: String,
236 pub reason: String,
238}
239
240#[derive(Deserialize, Serialize, Clone, Debug)]
242pub struct AnalysisMacroProfile {
243 pub name: String,
245 pub rvas: Vec<u64>,
247}
248
249#[derive(Deserialize, Serialize, Clone, Debug)]
251pub struct AnalysisResult {
252 pub environment: PeEnvironment,
254 pub functions: Vec<AnalysisFunction>,
256 pub rejects: Vec<AnalysisReject>,
258 pub macros: Vec<AnalysisMacroProfile>,
260}
261
262#[derive(Debug, Serialize, Deserialize)]
264pub enum YamlSymbol {
265 Name(String),
267 Rva(u64),
269}
270
271#[derive(Debug, Serialize, Deserialize)]
273pub struct YamlProfile {
274 pub name: String,
276 pub passes: Vec<ObfuscationPass>,
278 pub compiler_settings: CDCompilerSettings,
280 pub symbols: Vec<YamlSymbol>,
282 pub color: Option<String>,
284}
285
286#[derive(Debug, Serialize, Deserialize)]
288pub struct YamlConfig {
289 pub version: String,
291 pub api_key: String,
293 pub timeout: u64,
296 pub input_file: PathBuf,
298 pub output_file: PathBuf,
300 pub pdb_file: Option<PathBuf>,
302 pub module_settings: CDModuleSettings,
304 pub profiles: Vec<YamlProfile>,
306}