English | δΈζ
Deobfuscation framework for Ghidra β the most comprehensive open-source deobfuscation toolkit for the Ghidra reverse engineering platform.
D810G brings D-810-level deobfuscation capabilities to Ghidra. It uses a hybrid Java + Python architecture: a Ghidra plugin handles UI and binary patching, while a Python engine powered by Z3, Unicorn, Capstone, and Keystone performs the heavy analysis.
| Module | Description |
|---|---|
| Control Flow Deflattening | OLLVM + Tigress CFF recovery via Unicorn emulation |
| MBA Simplification | 96 rules with multi-pass iterative simplification and Z3 verification |
| Opaque Predicate Elimination | Standard + advanced (number theory, integer arithmetic) |
| Bogus Control Flow Removal | Detect and strip fake branches guarded by opaque predicates |
| Dead Code Elimination | BFS reachability analysis + NOP patching |
| String Decryption | XOR, multi-byte XOR, RC4, substitution table, ROT-N |
| VM Devirtualization | Tigress VM dispatcher detection, handler classification, bytecode tracing |
| Full Pipeline | 7-pass auto-chaining with fixpoint iteration |
| Standalone CLI | Use without Ghidra: simplify, opaque, interactive, pipeline |
| Ghidra Analyzer | One-click automatic deobfuscation during analysis |
git clone https://github.com/overkazaf/D810G.git
cd D810G
python3 -m venv .venv && source .venv/bin/activate
pip install z3-solver unicorn keystone-engine capstone$ PYTHONPATH=python python -m d810g_engine cli simplify "(x | y) - (x & y)"
(x | y) - (x & y)
β (x ^ y) (Z3 verified)
Rule: mba_xor_1
$ PYTHONPATH=python python -m d810g_engine cli simplify --deep \
"((x | y) - (x & y)) ^ ((x | y) - (x & y))"
((x | y) - (x & y)) ^ ((x | y) - (x & y))
β ((x ^ y) ^ ((x | y) - (x & y))) (step 1, mba_xor_1)
β ((x ^ y) ^ (x ^ y)) (step 2, mba_xor_1)
β 0 (step 3, mba_zero_1)
Final: Z3 verified equivalent
Iterations: 3, fixpoint: True
$ PYTHONPATH=python python -m d810g_engine cli opaque "x == x"
x == x
β ALWAYS TRUE β opaque, can be eliminated
$ PYTHONPATH=python python -m d810g_engine cli opaque "(x & 1) == 2"
(x & 1) == 2
β ALWAYS FALSE β opaque, can be eliminated
$ PYTHONPATH=python python -m d810g_engine cli opaque "x > 5"
x > 5
β DYNAMIC β real condition, keep as-is
$ PYTHONPATH=python python -m d810g_engine cli interactive
D810G Interactive Rule Editor
Loaded 96 rules from 6 files
d810g> test (x | y) - (x & y)
β (x ^ y) [Z3 verified]
Rule: mba_xor_1
d810g> verify (x & y) + (x ^ y) = x | y
8-bit: EQUIVALENT
16-bit: EQUIVALENT
32-bit: EQUIVALENT
64-bit: EQUIVALENT
d810g> add my_rule ~(~x & ~y) = x | y
Added rule 'my_rule': ~(~x & ~y) -> x | y [verified]
PYTHONPATH=python python -m d810g_engine cli simplify "<expr>" # one-shot simplify
PYTHONPATH=python python -m d810g_engine cli simplify --deep "<expr>" # multi-pass
PYTHONPATH=python python -m d810g_engine cli opaque "<condition>" # classify predicate
PYTHONPATH=python python -m d810g_engine cli rules # list all 96 rules
PYTHONPATH=python python -m d810g_engine cli rules --verify # Z3-verify all rules
PYTHONPATH=python python -m d810g_engine cli batch < exprs.txt # batch simplify
PYTHONPATH=python python -m d810g_engine cli interactive # REPL mode
PYTHONPATH=python python -m d810g_engine cli pipeline input.json # full pipelineD810G ships with 8 interactive demo scripts showcasing every module. Run them all at once or individually:
# Run all demos
PYTHONPATH=python python demo/demo_all.py
# Or run individually
PYTHONPATH=python python demo/demo_mba.py # MBA simplification (7 examples + Z3 proof table)
PYTHONPATH=python python demo/demo_deep_mba.py # Multi-pass iterative simplification
PYTHONPATH=python python demo/demo_opaque.py # Opaque predicate detection (always_true/false/dynamic)
PYTHONPATH=python python demo/demo_bcf.py # Bogus control flow removal (3-layer BCF + ASCII diagrams)
PYTHONPATH=python python demo/demo_deflat.py # Control flow deflattening (OLLVM state machine)
PYTHONPATH=python python demo/demo_strings.py # String decryption (XOR / RC4 / multi-byte / ROT-N)
PYTHONPATH=python python demo/demo_vm.py # VM devirtualization (handler table + Fibonacci pseudocode)
PYTHONPATH=python python demo/demo_pipeline.py # Full 7-pass pipeline with fixpoint iteration- Build the extension (see Building from Source)
- In Ghidra: File > Install Extensions > Add extension (select the zip)
- Right-click any function β D810G > Deobfuscate Function
- Results appear in the D810G Results panel
D810G includes a Ghidra Analyzer that automatically detects and deobfuscates functions during analysis:
- Open Analysis > Auto Analyze options
- Enable D810G Deobfuscation
- Run analysis β D810G scans all functions for obfuscation patterns and deobfuscates suspicious ones
analyzeHeadless /path/to/project Project -import binary.exe \
-postScript headless_deobfuscate.pyThe full pipeline runs 7 passes in optimal order, iterating until no more changes:
| Technique | Status | Details |
|---|---|---|
| OLLVM Control Flow Flattening | β | Switch-dispatch + Unicorn emulation + Keystone patching |
| Tigress CFF (indirect jump) | β | Jump table detection and resolution |
| Tigress CFF (if-chain) | β | Sequential comparison chain detection |
| OLLVM Bogus Control Flow | β | Opaque predicate-guarded fake branch removal |
| MBA Expressions | β | 96 rules, multi-pass iterative, sub-expression recursive |
| Opaque Predicates (standard) | β | Z3 bitvector satisfiability analysis |
| Opaque Predicates (advanced) | β | Integer arithmetic fallback + number theory patterns |
| Dead Code Elimination | β | BFS reachability + NOP fill (x86/ARM64/ARM32) |
| String Encryption (XOR) | β | Single-byte, multi-byte, XOR-with-index |
| String Encryption (RC4) | β | Brute-force key search |
| String Encryption (substitution) | β | ROT-N and custom lookup tables |
| Tigress VM (detection) | β | Dispatcher detection + handler classification |
| Tigress VM (bytecode tracing) | β | Execution simulation + pseudocode generation |
| Full Pipeline | β | 7-pass auto-chain with fixpoint iteration |
| Standalone CLI | β | simplify, opaque, rules, batch, interactive, pipeline |
| Ghidra Analyzer | β | Automatic analysis integration |
| Ghidra Headless | β | Batch scan via analyzeHeadless |
| Architecture | Deflattening | Patching | Dead Code |
|---|---|---|---|
| x86_64 | β | β | β |
| ARM64 (AArch64) | β | β | β |
| ARM32 | β | β | β |
D810G ships with 96 rules across 6 rule files:
| Rule Set | Count | Description |
|---|---|---|
mba_basic.json |
7 | Fundamental MBA identities (XOR, AND, OR equivalences) |
mba_hackers_delight.json |
16 | Bit manipulation from Hacker's Delight (abs, min, max, De Morgan) |
mba_ollvm.json |
10 | OLLVM instruction substitution patterns |
mba_constant_folding.json |
10 | Algebraic identities and constant folding |
mba_advanced.json |
28 | Advanced MBA patterns (nested, multi-variable, compound) |
mba_chains.json |
25 | Chained MBA transformations for deep simplification |
Create a JSON file in data/rules/:
{
"name": "my_rules",
"description": "Custom MBA rules",
"rules": [
{
"id": "my_xor_1",
"pattern": "(x | y) ^ (x & y)",
"replacement": "x ^ y",
"commutative": true,
"description": "XOR via OR XOR AND"
}
]
}Or use the interactive editor:
PYTHONPATH=python python -m d810g_engine cli interactive
d810g> add my_rule (x | y) ^ (x & y) = x ^ y
d810g> save my_rules.jsongit clone https://github.com/overkazaf/D810G.git
cd D810G
python3 -m venv .venv && source .venv/bin/activate
pip install z3-solver unicorn keystone-engine capstone# Build
export GHIDRA_INSTALL_DIR=/path/to/ghidra_11.x
cd D810G
$GHIDRA_INSTALL_DIR/support/gradle/gradlew buildExtension
# Install
# In Ghidra: File > Install Extensions > select dist/*.zip
# Set up venv in the extension directory:
cd <ghidra_extensions>/D810G
python3 -m venv .venv && source .venv/bin/activate
pip install z3-solver unicorn keystone-engine capstone- JDK 17+
- Ghidra 11.x
- Python 3.11+
pip install z3-solver unicorn keystone-engine capstone pytest
# Build Ghidra extension
export GHIDRA_INSTALL_DIR=/path/to/ghidra
$GHIDRA_INSTALL_DIR/support/gradle/gradlew buildExtension
# Run all 398 tests
source .venv/bin/activate
PYTHONPATH=python python -m pytest test/ -vpython -m pytest test/test_deflattener.py # CFF + Unicorn emulation (12 tests)
python -m pytest test/test_tigress.py # Tigress variants (6 tests)
python -m pytest test/test_mba.py # MBA matching (9 tests)
python -m pytest test/test_mba_extended.py # 96-rule Z3 verification (41 tests)
python -m pytest test/test_mba_deep.py # Multi-pass simplification (8 tests)
python -m pytest test/test_opaque.py # Opaque predicates (6 tests)
python -m pytest test/test_opaque_advanced.py # Advanced predicates (11 tests)
python -m pytest test/test_bcf.py # Bogus control flow (10 tests)
python -m pytest test/test_dce.py # Dead code elimination (14 tests)
python -m pytest test/test_strings.py # String decryption (19 tests)
python -m pytest test/test_virtualization.py # VM analysis (13 tests)
python -m pytest test/test_vm_tracer.py # Bytecode tracing (13 tests)
python -m pytest test/test_pipeline.py # Full pipeline (9 tests)
python -m pytest test/test_cli.py # CLI commands (7 tests)
python -m pytest test/test_interactive.py # Interactive editor (10 tests)
python -m pytest test/test_protocol.py # IPC protocol (4 tests)
python -m pytest test/test_parser.py # Shared expression parser (12 tests)
python -m pytest test/test_vm_disasm.py # VM disassembly + Capstone (10 tests)
python -m pytest test/test_mba_advanced_chains.py # Advanced + chained MBA rules (35 tests)
python -m pytest test/test_real_binary.py # Realistic binary test cases (12 tests)
python -m pytest test/test_integration.py # Integration (9 tests)D810G/
βββ src/main/java/d810g/ # Ghidra plugin (Java)
β βββ D810GPlugin.java # Plugin entry point
β βββ D810GAnalyzer.java # Auto-analysis integration
β βββ engine/ # Python process management + JSON-RPC
β βββ core/ # Orchestrator, PatchManager, PcodeUtils
β βββ actions/ # Right-click menu actions
β βββ ui/ # Results panel
βββ python/d810g_engine/ # Analysis engine (Python)
β βββ server.py # JSON-RPC server
β βββ cli.py # Standalone CLI
β βββ interactive.py # Interactive rule editor
β βββ deflattener/ # OLLVM + Tigress + Unicorn
β βββ mba/ # Rules + matcher + Z3 verifier
β βββ opaque/ # Standard + advanced predicates
β βββ bcf/ # Bogus control flow
β βββ dce/ # Dead code elimination
β βββ strings/ # String decryption (XOR/RC4/sub)
β βββ virtualization/ # VM analysis + bytecode tracer
β βββ pipeline/ # Multi-pass orchestrator
βββ data/rules/ # MBA rule definitions (96 rules)
βββ test/ # 398 tests
βββ demo/ # Demo scripts
βββ scripts/ # Headless analysis scripts
βββ .github/workflows/ # CI (Python 3.11/3.12/3.13)
D810G is inspired by:
- D-810 β the original IDA Pro deobfuscation plugin by eShard
- D-810-ng β community fork with updates
Built to bring these capabilities β and more β to the Ghidra reverse engineering ecosystem.
Apache License 2.0. See LICENSE for details.