1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
//! Deobfuscation framework for .NET assemblies.
//!
//! This module provides a comprehensive deobfuscation system built on SSA
//! (Static Single Assignment) form and a technique-oriented architecture
//! where each protection type is a self-contained module.
//!
//! # Architecture
//!
//! The deobfuscation pipeline is technique-oriented:
//!
//! ```text
//! ┌─────────────────────────────────────────────────────────────────────────┐
//! │ Deobfuscation Pipeline │
//! ├─────────────────────────────────────────────────────────────────────────┤
//! │ Input: Assembly (CilObject) │
//! │ │ │
//! │ ▼ │
//! │ Phase 1: Technique Detection │
//! │ • Each registered technique runs detect() on the assembly │
//! │ • Produces Detection with confidence, evidence, and findings │
//! │ │ │
//! │ ▼ │
//! │ Phase 2: Byte-level Transforms (Technique::byte_transform) │
//! │ • Anti-tamper decryption, metadata repair, resource extraction │
//! │ • PE regeneration between transforms │
//! │ │ │
//! │ ▼ │
//! │ Phase 2.5: Post-transform IL Re-detection │
//! │ • Byte transforms may reveal new patterns in decrypted method bodies │
//! │ │ │
//! │ ▼ │
//! │ Phase 3: SSA Construction │
//! │ • Build call graph, SSA representations, interprocedural analysis │
//! │ │ │
//! │ ▼ │
//! │ Phase 3.5: SSA Detection + Technique Initialization │
//! │ • SSA-level detection via Technique::detect_ssa() │
//! │ • Technique initialization (register decryptors, hooks, etc.) │
//! │ • Technique-provided passes + compiler passes in fixpoint scheduler │
//! │ │ │
//! │ ▼ │
//! │ Phase 4: Neutralization │
//! │ • Remove protection infrastructure from module .cctor │
//! │ │ │
//! │ ▼ │
//! │ Phase 5: Code Generation │
//! │ • Generate CIL bytecode from optimized SSA │
//! │ │ │
//! │ ▼ │
//! │ Phase 6: Cleanup │
//! │ • Remove dead types, methods, fields, and metadata artifacts │
//! │ │ │
//! │ ▼ │
//! │ Phase 7: Attribution │
//! │ • Identify obfuscator from technique detection signatures │
//! │ │ │
//! │ ▼ │
//! │ Output: DeobfuscationResult (stats, technique results, attribution) │
//! └─────────────────────────────────────────────────────────────────────────┘
//! ```
//!
//! # Key Components
//!
//! ## Engine
//!
//! [`DeobfuscationEngine`](crate::deobfuscation::DeobfuscationEngine) is the main entry point:
//!
//! - Orchestrates detection, byte transforms, SSA passes, and cleanup
//! - Manages the [`TechniqueRegistry`](crate::deobfuscation::TechniqueRegistry) of all registered techniques
//! - Coordinates the pass scheduler for fixpoint iteration
//!
//! ## Technique System
//!
//! Each protection technique is a self-contained module implementing:
//!
//! - [`Technique`](crate::deobfuscation::Technique) — unified trait: `detect()`, `byte_transform()`, `ssa_phase()`, `detect_ssa()`, etc.
//!
//! ## Pass System
//!
//! SSA-based transformation passes ([`crate::compiler::SsaPass`]):
//!
//! - [`crate::compiler::PassScheduler`] — Manages pass execution order and fixpoint iteration
//! - [`crate::compiler::EventLog`] — Tracks changes made by passes
//! - [`AnalysisContext`](crate::deobfuscation::AnalysisContext) — Shared interprocedural analysis data
//!
//! # Usage
//!
//! ```rust,ignore
//! use dotscope::deobfuscation::{DeobfuscationEngine, EngineConfig};
//!
//! let config = EngineConfig::default();
//! let engine = DeobfuscationEngine::new(config);
//!
//! let (deobfuscated, result) = engine.process_file("obfuscated.dll")?;
//! println!("{}", result.summary());
//! ```
pub
// Public API — used by CLI, tests, examples, and external consumers
pub use ;
pub use ;
pub use ;
pub use DeobfuscationEngine;
pub use ;
pub use SmartRenameConfig;
pub use DeobfuscationResult;
pub use ;
// Crate-internal re-exports (only items that are actually imported via this path)
pub use ProcessCell;
pub use ;
pub use EmulationTemplatePool;