seifreed/r2morph
GitHub: seifreed/r2morph
基于 radare2 的二进制变形引擎,支持多种变异操作并内置验证与审计报告功能。
Stars: 45 | Forks: 5
r2morph
具备结构化验证与报告功能的变形变异引擎
## 概述 **r2morph** 是一个优先考虑变异的引擎,用于应用变形二进制转换,并具备显式验证、回滚和机器可读报告功能。它利用 **radare2** 和 **r2pipe** 来分析二进制文件,应用跟踪的变异,并在导出前验证结果。 ### 主要特性 | 特性 | 描述 | |---------|-------------| | **跟踪变异** | 每个应用的变异都可以记录地址、字节和反汇编代码 | | **验证管道** | 引擎内部的结构化验证,可选的运行时验证,失败时回滚 | | **机器可读报告** | 导出 JSON 报告,用于 CI、回归检查和可审计性 | | **CLI + Python API** | 作为 `mutate`、`validate`、`report` 运行,或作为库嵌入 | | **radare2 支持的分析** | 重用 radare2/r2pipe 进行反汇编和二进制元数据获取 | | **实验性模块** | 反虚拟化、增强分析、插桩和反分析辅助工具仍作为次要/实验性功能 | ## 安装说明 ### 前置条件 - Python 3.10+ - radare2 installed #### 安装 radare2 ``` git clone https://github.com/radareorg/radare2 cd radare2 sys/install.sh ``` ### 安装 r2morph ``` # Basic installation pip install r2morph # Enhanced analysis capabilities pip install "r2morph[enhanced]" # All optional features pip install "r2morph[all]" ``` ### 开发环境安装 ``` git clone https://github.com/seifreed/r2morph.git cd r2morph pip install -e . # Dev tooling pip install -e ".[dev]" ``` ## 产品重心 `r2morph` 的重心围绕单一产品: **加载二进制 -> 应用跟踪变异 -> 验证 -> 导出二进制 + 报告** 稳定的核心是变异 + 验证。高级逆向工程工作流虽可在仓库中使用,但属于次要功能,应视为实验性的。 请参阅 [docs/ROADMAP.md](docs/ROADMAP.md) 了解实施路线图和当前阶段状态。 ## 支持矩阵 ### 稳定核心 | 领域 | 支持 | 稳定性 | |------|-----------|-----------| | 格式 | ELF | 稳定 | | 架构 | x86_64 | 稳定 | | 变异 | `nop`, `substitute`, `register` | 稳定 | | 验证器 | `structural`, `runtime` | 稳定 / 支持 | | 输出 | JSON 报告 + 变异后的二进制 | 稳定 | ### 实验性 / 次要 | 领域 | 支持 | 稳定性 | |------|-----------|-----------| | 格式 | PE, Mach-O | 实验性 | | 变异 | `expand`, `block`, `opaque`, `dead-code`, `cff` | 实验性 | | 验证 | symbolic equivalence | 实验性 | | 分析 | devirtualization, Frida, anti-analysis, packer analysis | 实验性 | ## 快速开始 ``` # Stable mutate + validate flow r2morph input_binary output_binary # Explicit mutate command with report r2morph mutate input_binary -o output_binary --report mutation_report.json # Reproducible stable mutation run r2morph mutate input_binary -o output_binary --seed 1337 # Runtime validation of an original/mutated pair r2morph validate input_binary output_binary # Runtime validation with a reusable corpus r2morph validate input_binary output_binary --corpus dataset/runtime_corpus.json ``` ## 使用说明 ### 命令行界面 ``` # Stable default flow r2morph input_binary output_binary # Stable tracked mutation flow r2morph mutate input_binary -o output_binary -m nop -m substitute -m register # Reproducible mutation selection r2morph mutate input_binary -o output_binary --seed 1337 # Experimental symbolic precheck mode r2morph mutate input_binary -o output_binary --validation-mode symbolic # Allow a limited symbolic pass explicitly r2morph mutate input_binary -o output_binary --validation-mode symbolic \ --allow-limited-symbolic -m register # Degrade a limited symbolic pass to runtime validation instead of blocking r2morph mutate input_binary -o output_binary --validation-mode symbolic \ --limited-symbolic-policy degrade-runtime -m register # Export a machine-readable report r2morph mutate input_binary -o output_binary --report report.json # Fail the CLI run unless the final report reaches a minimum symbolic severity r2morph mutate input_binary -o output_binary --report report.json \ --min-severity bounded-only # Fail unless a specific pass reaches the required local severity r2morph mutate input_binary -o output_binary --report report.json \ --require-pass-severity InstructionSubstitution=bounded-only # Short mutation aliases also work in pass severity gating r2morph mutate input_binary -o output_binary --report report.json \ --require-pass-severity nop=not-requested # The generated report preserves gate requests and outcomes in `gate_evaluation` # Validate a mutated binary against the original r2morph validate input_binary output_binary # Validate with a JSON corpus of runtime cases r2morph validate input_binary output_binary --corpus dataset/runtime_corpus.json # Ignore trailing whitespace differences in stdout/stderr r2morph validate input_binary output_binary --corpus dataset/runtime_corpus.json --normalize-whitespace # Run mutate with runtime validation backed by a real corpus r2morph mutate input_binary -o output_binary \ --validation-mode runtime \ --runtime-corpus dataset/runtime_corpus.json # Display a saved report with symbolic coverage summaries and mismatch triage when available r2morph report report.json # Use the saved report as a CI gate r2morph report report.json --require-results --min-severity mismatch # Triage only runs where persisted CLI gates failed r2morph report report.json --only-failed-gates --summary-only # The summary includes compact gate failure causes for fast triage # Restrict persisted gate failures to one expected severity r2morph report report.json --only-failed-gates --only-expected-severity clean --summary-only # Restrict persisted gate failures to one pass r2morph report report.json --only-failed-gates --only-pass-failure NopInsertion --summary-only # Stable mutation aliases work for gate triage too r2morph report report.json --only-failed-gates --only-pass-failure nop --summary-only # Triage only symbolic observable mismatches r2morph report report.json --only-mismatches # Restrict the report to one pass, optionally combined with mismatch triage r2morph report report.json --only-pass InstructionSubstitution --only-mismatches # Stable mutation aliases also work in pass filtering r2morph report report.json --only-pass nop # Filter directly by symbolic status r2morph report report.json --only-status bounded-step-observable-mismatch # Show only reports where the effective validation mode was degraded r2morph report report.json --only-degraded # The report summary includes the degraded pass set and symbolic confidence for each cause # Show only the textual summary for terminal triage r2morph report report.json --summary-only # Export a filtered report JSON for CI or post-processing r2morph report report.json --only-pass InstructionSubstitution --output filtered-report.json # Fail in CI when a filtered view has no matching mutations r2morph report report.json --only-pass InstructionSubstitution --require-results # Fail in CI when a filtered gate view has no matching failures r2morph report report.json --only-failed-gates --only-expected-severity clean --require-results r2morph report report.json --only-failed-gates --only-pass-failure nop --require-results # The exported JSON includes `filtered_summary` for the active view r2morph report report.json --only-status bounded-step-passed --output filtered-report.json # `filtered_summary.symbolic_statuses` exposes the status distribution for the current view r2morph report report.json --only-pass InstructionSubstitution --output filtered-report.json # Gate-focused filtered views also preserve `gate_failures`, `gate_failure_priority`, # `gate_failure_severity_priority`, and normalized `report_filters` r2morph report report.json --only-failed-gates --only-pass-failure nop --output filtered-report.json ``` #### 报告过滤器快速参考 | 过滤器 | 用途 | 示例 | | --- | --- | --- | | `--only-pass为逆向工程社区倾情奉献
标签:CTF工具, DAST, DNS 反向解析, DNS 解析, Homebrew安装, Python, r2pipe, radare2, 二进制修补, 二进制变换, 二进制安全, 云资产清单, 代码变异, 代码混淆, 变形引擎, 对称加密, 恶意软件分析, 无后门, 汇编分析, 漏洞搜索, 自动化审计, 逆向工具, 逆向工程, 防病毒规避