1use serde::{Deserialize, Serialize};
8
9pub const YAML_CONFIG_VERSION: &str = "1.0.6";
11
12#[derive(Debug, Serialize, Deserialize, Clone)]
14pub enum MutationEngineExtension {
15 Generic,
17 SSE3,
19 SSE42,
21}
22
23#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
25pub enum PeEnvironment {
26 UserMode,
28 KernelMode,
30 UEFI,
32}
33
34#[derive(Debug, Serialize, Deserialize, Clone)]
36pub struct LifterSettings {
37 pub lift_calls: bool,
39 pub calling_convention: String,
41 pub max_stack_copy_size: u32,
43 pub split_on_calls_fallback: bool,
45}
46
47#[derive(Debug, Serialize, Deserialize, Clone)]
49pub struct OptimizationSettings {
50 pub constant_propagation: bool,
52 pub instruction_combine: bool,
54 pub dead_code_elim: bool,
56 pub prune_useless_block_params: bool,
58 pub iterations: u32,
60}
61
62#[derive(Debug, Serialize, Deserialize, Clone)]
64pub struct AssemblerSettings {
65 pub shuffle_basic_blocks: bool,
67 pub instruction_prefix: String,
69 pub random_prefix_chance: f64,
71}
72
73#[derive(Debug, Serialize, Deserialize, Clone)]
75pub struct CompilerSettings {
76 pub assembler_settings: AssemblerSettings,
78 pub optimization_settings: OptimizationSettings,
80 pub lifter_settings: LifterSettings,
82}
83
84#[derive(Default, Debug, Serialize, Deserialize)]
86pub struct FakePdbString {
87 pub enabled: bool,
89 pub value: String,
91}
92
93#[derive(Default, Debug, Serialize, Deserialize)]
95pub struct CustomSectionName {
96 pub enabled: bool,
98 pub value: String,
100}
101
102#[derive(Debug, Serialize, Deserialize)]
104pub struct ModuleSettings {
105 #[serde(default)]
107 pub ida_crasher: bool,
108 #[serde(default)]
110 pub import_protection: bool,
111 #[serde(default)]
113 pub pack_output_file: bool,
114 #[serde(default)]
116 pub obscure_entry_point: bool,
117 #[serde(default)]
120 pub clear_unwind_info: bool,
121 #[serde(default)]
123 pub fake_pdb_string: FakePdbString,
124 #[serde(default)]
126 pub custom_section_name: CustomSectionName,
127}
128
129#[derive(Debug, Serialize, Deserialize, Clone)]
131pub struct Semantics {
132 #[serde(default)]
133 pub add: bool,
134 #[serde(default)]
135 pub sub: bool,
136 #[serde(default)]
137 pub and: bool,
138 #[serde(default)]
139 pub xor: bool,
140 #[serde(default)]
141 pub or: bool,
142 #[serde(default)]
143 pub not: bool,
144 #[serde(default)]
145 pub neg: bool,
146}
147
148#[derive(Debug, Serialize, Deserialize, Clone)]
150pub struct BitWidths {
151 #[serde(default)]
152 pub bit8: bool,
153 #[serde(default)]
154 pub bit16: bool,
155 #[serde(default)]
156 pub bit32: bool,
157 #[serde(default)]
158 pub bit64: bool,
159}
160
161#[derive(Debug, Serialize, Deserialize, Clone)]
165pub struct SsaOrigins {
166 pub normal: bool,
167 pub memop: bool,
168 pub fp_based_memop: bool,
169 pub sp_based_memop: bool,
170}
171
172#[derive(Debug, Serialize, Deserialize, Clone)]
174pub struct LoopEncodeSemantics {
175 pub iterations: u32,
177 pub probability: u32,
179 pub semantics: Semantics,
181 pub bitwidths: BitWidths,
183 pub ethnicities: SsaOrigins,
184}
185
186#[derive(Debug, Serialize, Deserialize, Clone)]
188pub struct MixedBooleanArithmetic {
189 pub iterations: u32,
190 pub probability: u32,
191 pub semantics: Semantics,
192 pub bitwidths: BitWidths,
193 pub ethnicities: SsaOrigins,
194}
195
196#[derive(Debug, Serialize, Deserialize, Clone)]
198pub struct MutationEngine {
199 pub iterations: u32,
200 pub probability: u32,
201 pub extension: MutationEngineExtension,
202 pub semantics: Semantics,
203 pub bitwidths: BitWidths,
204 pub ethnicities: SsaOrigins,
205}
206
207#[derive(Debug, Serialize, Deserialize, Clone)]
209pub struct IDADecompilerCrasher;
210
211#[derive(Debug, Serialize, Deserialize, Clone)]
213pub struct SuppressConstants {
214 pub mba_enhance: bool,
215 pub ethnicities: SsaOrigins,
216}
217
218#[derive(Debug, Serialize, Deserialize, Clone)]
221pub struct ObscureConstants {
222 pub mba_enhance: bool,
223 pub probability: u32,
224 pub iterations: u32,
225 pub bitwidths: BitWidths,
226 pub ethnicities: SsaOrigins,
227}
228
229#[derive(Debug, Serialize, Deserialize, Clone)]
231pub struct ObscureReferences {
232 pub mba_enhance: bool,
233}
234
235#[derive(Debug, Serialize, Deserialize, Clone)]
237pub struct ObscureControlFlow {
238 pub mba_enhance: bool,
239 pub probability: u32,
240}
241
242#[derive(Debug, Serialize, Deserialize, Clone)]
244pub struct TetherExtraction {
245 pub min_extract_len: usize,
248 pub endpoint: String,
250 pub port: u16,
252 pub server_public_key: String,
255}
256
257#[derive(Debug, Serialize, Deserialize, Clone)]
259pub struct OpaqueBlockDuplication {
260 pub iterations: u32,
262 pub probability: u32,
264}
265
266#[derive(Debug, Serialize, Deserialize, Clone)]
268pub struct SplitBlockPass {
269 pub threshold: u32,
271}
272
273#[derive(Debug, Serialize, Deserialize, Clone)]
275pub struct LeaEncodeImm {
276 pub mba_enhance: bool,
277 pub iterations: u32,
279 pub probability: u32,
281 pub ethnicities: SsaOrigins,
282}
283
284#[derive(Debug, Serialize, Deserialize, Clone)]
285pub struct SigBreaker {
286 pub shuffle_insts: bool,
287 pub random_segment_selector: bool,
288 pub calling_convention: String,
290 pub shuffle_opcodes: bool,
291 pub instruction_substitution: bool,
292}
293
294#[derive(Debug, Serialize, Deserialize, Clone)]
296#[serde(tag = "type")]
297pub enum ObfuscationPass {
298 LoopEncodeSemantics(LoopEncodeSemantics),
299 MixedBooleanArithmetic(MixedBooleanArithmetic),
300 MutationEngine(MutationEngine),
301 TetherExtraction(TetherExtraction),
302 SplitBlockPass(SplitBlockPass),
303 OpaqueBlockDuplication(OpaqueBlockDuplication),
304 ObscureControlFlow(ObscureControlFlow),
305 LeaEncodeImm(LeaEncodeImm),
306 ObscureConstants(ObscureConstants),
307 SuppressConstants(SuppressConstants),
308 ObscureReferences(ObscureReferences),
309 SigBreaker(SigBreaker),
310 IDADecompilerCrasher,
311 AntiEmulator,
312}
313
314#[derive(Debug, Serialize, Deserialize)]
316pub struct Profile {
317 pub name: String,
319 pub passes: Vec<ObfuscationPass>,
321 pub compiler_settings: CompilerSettings,
323 pub symbols: Vec<u64>,
325}
326
327#[derive(Debug, Serialize, Deserialize)]
329pub struct Config {
330 pub module_settings: ModuleSettings,
332 pub profiles: Vec<Profile>,
334}
335
336#[derive(Deserialize, Serialize, Clone, Debug)]
338pub struct AnalysisFunction {
339 pub rva: u64,
341 pub symbol: String,
343 pub ref_count: usize,
345}
346
347#[derive(Deserialize, Serialize, Clone, Debug)]
349pub struct AnalysisReject {
350 pub rva: u64,
352 pub symbol: String,
354 pub ty: String,
356 pub reason: String,
358}
359
360#[derive(Deserialize, Serialize, Clone, Debug)]
362pub struct AnalysisMacroProfile {
363 pub name: String,
365 pub rvas: Vec<u64>,
367}
368
369#[derive(Deserialize, Serialize, Clone, Debug)]
371pub struct AnalysisResult {
372 pub environment: PeEnvironment,
374 pub functions: Vec<AnalysisFunction>,
376 pub rejects: Vec<AnalysisReject>,
378 pub macros: Vec<AnalysisMacroProfile>,
380}
381
382#[derive(Deserialize, Serialize, Clone, Debug)]
383pub struct DisassemblySettings {
384 pub allow_code_reads_and_writes: bool,
385 pub allow_unknown_indirect_jumps: bool,
386 pub allow_mismatched_branch_counts: bool,
387 pub thunk_mismatched_branch_counts: bool,
388 pub thunk_branch_target_identifiers: bool,
389 pub thunk_no_prev_block: bool,
390 pub thunk_data_references: bool,
391 pub always_thunk_entry: bool,
392 pub follow_faulting_instructions: bool,
393 pub pass_interrupts: bool,
394 pub pass_exceptions: bool,
395 pub aggressive_pointer_analysis: bool,
396 pub perform_relocation_analysis: bool,
397 pub explore_catch_funclet_continuations: bool,
398}
399
400#[derive(Debug, Serialize, Deserialize)]
402pub enum YamlSymbol {
403 Name(String),
405 Rva(u64),
407 All,
409}
410
411#[derive(Debug, Serialize, Deserialize)]
413pub struct YamlProfile {
414 pub name: String,
416 pub passes: Vec<ObfuscationPass>,
418 pub compiler_settings: CompilerSettings,
420 pub symbols: Vec<YamlSymbol>,
422}
423
424#[derive(Debug, Serialize, Deserialize)]
426pub struct YamlConfig {
427 pub version: String,
429 pub disassembly_settings: DisassemblySettings,
431 pub module_settings: ModuleSettings,
433 pub profiles: Vec<YamlProfile>,
435}