use serde::{Deserialize, Serialize};
pub const YAML_CONFIG_VERSION: &str = "1.0.6";
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum MutationEngineExtension {
Generic,
SSE3,
SSE42,
}
#[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)]
pub enum PeEnvironment {
UserMode,
KernelMode,
UEFI,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct LifterSettings {
pub lift_calls: bool,
pub calling_convention: String,
pub max_stack_copy_size: u32,
pub split_on_calls_fallback: bool,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct OptimizationSettings {
pub constant_propagation: bool,
pub instruction_combine: bool,
pub dead_code_elim: bool,
pub prune_useless_block_params: bool,
pub iterations: u32,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct AssemblerSettings {
pub shuffle_basic_blocks: bool,
pub instruction_prefix: String,
pub random_prefix_chance: f64,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct CompilerSettings {
pub assembler_settings: AssemblerSettings,
pub optimization_settings: OptimizationSettings,
pub lifter_settings: LifterSettings,
}
#[derive(Default, Debug, Serialize, Deserialize)]
pub struct FakePdbString {
pub enabled: bool,
pub value: String,
}
#[derive(Default, Debug, Serialize, Deserialize)]
pub struct CustomSectionName {
pub enabled: bool,
pub value: String,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct ModuleSettings {
#[serde(default)]
pub ida_crasher: bool,
#[serde(default)]
pub import_protection: bool,
#[serde(default)]
pub pack_output_file: bool,
#[serde(default)]
pub obscure_entry_point: bool,
#[serde(default)]
pub clear_unwind_info: bool,
#[serde(default)]
pub fake_pdb_string: FakePdbString,
#[serde(default)]
pub custom_section_name: CustomSectionName,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Semantics {
#[serde(default)]
pub add: bool,
#[serde(default)]
pub sub: bool,
#[serde(default)]
pub and: bool,
#[serde(default)]
pub xor: bool,
#[serde(default)]
pub or: bool,
#[serde(default)]
pub not: bool,
#[serde(default)]
pub neg: bool,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct BitWidths {
#[serde(default)]
pub bit8: bool,
#[serde(default)]
pub bit16: bool,
#[serde(default)]
pub bit32: bool,
#[serde(default)]
pub bit64: bool,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct SsaOrigins {
pub normal: bool,
pub memop: bool,
pub fp_based_memop: bool,
pub sp_based_memop: bool,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct LoopEncodeSemantics {
pub iterations: u32,
pub probability: u32,
pub semantics: Semantics,
pub bitwidths: BitWidths,
pub ethnicities: SsaOrigins,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct MixedBooleanArithmetic {
pub iterations: u32,
pub probability: u32,
pub semantics: Semantics,
pub bitwidths: BitWidths,
pub ethnicities: SsaOrigins,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct MutationEngine {
pub iterations: u32,
pub probability: u32,
pub extension: MutationEngineExtension,
pub semantics: Semantics,
pub bitwidths: BitWidths,
pub ethnicities: SsaOrigins,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct IDADecompilerCrasher;
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct SuppressConstants {
pub mba_enhance: bool,
pub ethnicities: SsaOrigins,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ObscureConstants {
pub mba_enhance: bool,
pub probability: u32,
pub iterations: u32,
pub bitwidths: BitWidths,
pub ethnicities: SsaOrigins,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ObscureReferences {
pub mba_enhance: bool,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct ObscureControlFlow {
pub mba_enhance: bool,
pub probability: u32,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct TetherExtraction {
pub min_extract_len: usize,
pub endpoint: String,
pub port: u16,
pub server_public_key: String,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct OpaqueBlockDuplication {
pub iterations: u32,
pub probability: u32,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct SplitBlockPass {
pub threshold: u32,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct LeaEncodeImm {
pub mba_enhance: bool,
pub iterations: u32,
pub probability: u32,
pub ethnicities: SsaOrigins,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct SigBreaker {
pub shuffle_insts: bool,
pub random_segment_selector: bool,
pub calling_convention: String,
pub shuffle_opcodes: bool,
pub instruction_substitution: bool,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(tag = "type")]
pub enum ObfuscationPass {
LoopEncodeSemantics(LoopEncodeSemantics),
MixedBooleanArithmetic(MixedBooleanArithmetic),
MutationEngine(MutationEngine),
TetherExtraction(TetherExtraction),
SplitBlockPass(SplitBlockPass),
OpaqueBlockDuplication(OpaqueBlockDuplication),
ObscureControlFlow(ObscureControlFlow),
LeaEncodeImm(LeaEncodeImm),
ObscureConstants(ObscureConstants),
SuppressConstants(SuppressConstants),
ObscureReferences(ObscureReferences),
SigBreaker(SigBreaker),
IDADecompilerCrasher,
AntiEmulator,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Profile {
pub name: String,
pub passes: Vec<ObfuscationPass>,
pub compiler_settings: CompilerSettings,
pub symbols: Vec<u64>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Config {
pub module_settings: ModuleSettings,
pub profiles: Vec<Profile>,
}
#[derive(Deserialize, Serialize, Clone, Debug)]
pub struct AnalysisFunction {
pub rva: u64,
pub symbol: String,
pub ref_count: usize,
}
#[derive(Deserialize, Serialize, Clone, Debug)]
pub struct AnalysisReject {
pub rva: u64,
pub symbol: String,
pub ty: String,
pub reason: String,
}
#[derive(Deserialize, Serialize, Clone, Debug)]
pub struct AnalysisMacroProfile {
pub name: String,
pub rvas: Vec<u64>,
}
#[derive(Deserialize, Serialize, Clone, Debug)]
pub struct AnalysisResult {
pub environment: PeEnvironment,
pub functions: Vec<AnalysisFunction>,
pub rejects: Vec<AnalysisReject>,
pub macros: Vec<AnalysisMacroProfile>,
}
#[derive(Deserialize, Serialize, Clone, Debug)]
pub struct DisassemblySettings {
pub allow_code_reads_and_writes: bool,
pub allow_unknown_indirect_jumps: bool,
pub allow_mismatched_branch_counts: bool,
pub thunk_mismatched_branch_counts: bool,
pub thunk_branch_target_identifiers: bool,
pub thunk_no_prev_block: bool,
pub thunk_data_references: bool,
pub always_thunk_entry: bool,
pub follow_faulting_instructions: bool,
pub pass_interrupts: bool,
pub pass_exceptions: bool,
pub aggressive_pointer_analysis: bool,
pub perform_relocation_analysis: bool,
pub explore_catch_funclet_continuations: bool,
}
#[derive(Debug, Serialize, Deserialize)]
pub enum YamlSymbol {
Name(String),
Rva(u64),
All,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct YamlProfile {
pub name: String,
pub passes: Vec<ObfuscationPass>,
pub compiler_settings: CompilerSettings,
pub symbols: Vec<YamlSymbol>,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct YamlConfig {
pub version: String,
pub disassembly_settings: DisassemblySettings,
pub module_settings: ModuleSettings,
pub profiles: Vec<YamlProfile>,
}