jcube3ai/raptor
GitHub: jcube3ai/raptor
一款面向 SOC 团队的自动化恶意软件静态逆向分析平台,通过多阶段分析管线自动提取风险评分、IOCs 及家族配置。
Stars: 0 | Forks: 0
# RAPTOR
### 威胁运营与响应逆向分析平台
## 🧬 什么是 RAPTOR?
RAPTOR 是一个**自包含的恶意软件逆向工程平台**,可自动执行静态二进制分析中最耗时的部分。它建立在独立的分析模块之上,为 SOC 分析师提供即时可用的判定结果——风险评分、MITRE ATT&CK TTPs、IOC 导出、家族配置解密以及完整的交互式仪表板——无需接触调试器或反汇编器。
## ⚡ 功能
### 🔬 分析 Pipeline — 17 个阶段
| 模块 | 功能说明 |
|---|---|
| **Magic Detector** | 通过 magic bytes 识别文件类型——绝不依赖扩展名 |
| **Entropy Scanner** | Shannon 熵 + 高熵区域映射——精确定位加壳/加密区段 |
| **PE Parser** | 完整的 PE 结构,60+ 可疑 API 导入标记,imphash,ssdeep 模糊哈希 |
| **Rich Header Parser** | 提取隐藏的编译器/链接器指纹——编译器版本、构建工具、`rich_hash` 枢纽 |
| **PE Overlay Detector** | 查找附加在最后一个 PE 节之后的数据——dropper/SFX payload 检测 |
| **ELF Parser** | 针对Linux和 IoT 恶意软件的完整 ELF 二进制分析 |
| **.NET Analyzer** | 基于 `dnfile` 的堆提取——用户字符串、类型名称、可疑方法、IOCs |
| **Packer ID** | 针对 UPX、Themida、VMProtect、MPRESS 及 20 多种 packer 的字节签名检测 |
| **Auto Unpacker** | 检测 UPX 并自动运行 `upx -d`——自动重新分析脱壳后的二进制文件 |
| **Language Detector** | 识别编译器/语言——.NET、Go、Rust、Nim、AutoIT、VB6、Python 等 |
| **XOR Engine** | 暴力破解所有 XOR 变体——单字节、多字节、滚动、已知明文、**已知恶意软件密钥表** |
| **RC4 Engine** | KSA 模式检测 + 短密钥暴力破解 |
| **AES Hunter** | S-box 模式检测、密钥候选提取、CBC/ECB 解密 |
| **Cipher Engine** | ChaCha20、Salsa20、DES、3DES、Blowfish |
| **Blob Pipeline** | 多层解码——提取 blob、尝试所有加密算法、递归、对解码后的 payload 进行 YARA 扫描 |
| **Key Recovery** | Hex/base64/UTF-16 密钥提取,RC4 KSA 逆向,AES S-box 检测,PBKDF2 派生 |
| **String Hunter** | ASCII + Unicode 提取,包括 XOR 恢复的字符串和 .NET 堆字符串 |
| **String Categorizer** | 对每个字符串进行分类——网络、文件系统、加密、命令、持久化、凭证、C2 指标、mutexes |
| **IOC Extractor** | IP、域名、URL、注册表项、mutexes、文件路径、加密钱包、named pipes |
| **Script Deobfuscator** | PowerShell、VBScript、JavaScript、Batch——多轮去混淆 + IOC 提取 |
| **Anti-Analysis Detector** | 反调试、反虚拟机、反沙箱、时间检查、规避技术检测 |
| **Family Config Extractor** | 解密完整的恶意软件配置——AsyncRAT、njRAT、Remcos、AgentTesla、Cobalt Strike 等 |
| **YARA Engine** | 包含 25+ 条内置规则,涵盖勒索软件、RATs、窃密程序、C2 框架 |
| **Risk Engine** | 0–100 的统一风险评分,MITRE ATT&CK 映射(60+ TTPs) |
| **VirusTotal** | 启动时进行哈希预检查(快速),完成时进行全面查询 |
### 🎯 情报层
- **风险评分 0–100** —— 来自所有检测信号的统一评分
- **MITRE ATT&CK 映射** —— 根据检测到的行为自动标记 TTP(60+ 映射)
- **IOC 导出** —— CSV、STIX2 和完整的 JSON,用于 SIEM/MISP 接入
- **家族配置解密** —— AsyncRAT AES-256-CBC + PBKDF2、Remcos RC4、Cobalt Strike beacon XOR 等
- **扫描历史** —— 跨会话的持久化分析日志
### 🖥 SOC Web 仪表板
- 拖放文件上传——支持任何格式
- 通过 Server-Sent Events 进行实时进度流传输
- **Triage 模式** (`?triage=1`) —— 跳过 blob pipeline,快速获得 5–15 秒的结果
- 14 个交互式结果标签页:概述、VirusTotal、YARA、API 导入、IOCs、MITRE ATT&CK、反分析、语言、.NET、配置、解密、熵、字符串、风险细分
- CyberChef 风格的 **Decoder Workbench**,用于手动解密
- 专为长时间分析会话设计的深色终端美学
## 🚀 快速开始
### 环境要求
- Python 3.10+
- Windows、Linux 或 macOS
### 安装
```
# Clone repo
git clone https://github.com/YOUR_USERNAME/raptor.git
cd raptor
# 安装依赖
pip install -r requirements.txt
# 仅限 Windows — 将 python-magic 替换为:
pip install python-magic-bin
```
### 可选:UPX 自动脱壳
```
# Ubuntu/Debian
sudo apt install upx-ucl
# macOS
brew install upx
# Windows
choco install upx
```
### 可选:VirusTotal 集成
```
# Linux/macOS
export VT_API_KEY=your_key_here
# Windows
set VT_API_KEY=your_key_here
```
### 运行
```
# 启动 web UI
python app.py
# 打开浏览器
http://localhost:5000
```
### CLI 模式(无需浏览器)
```
# 分析单个文件
python main.py --file sample.exe
# 批量分析文件夹
python main.py --dir ./samples/
# 输出 JSON 到 stdout
python main.py --file sample.exe --json
```
## 🧪 使用合成样本进行测试
没有样本?生成安全的合成测试文件来测试每个模块:
```
python tests/create_test_samples.py
# 然后对它们运行
python main.py --dir samples/test/
```
## 📁 项目结构
```
raptor/
├── app.py ← Flask web server + main analysis pipeline
├── main.py ← CLI entry point
├── requirements.txt
│
├── core/ ← Analysis engine modules
│ ├── aes_hunter.py ← AES S-box detection + key extraction
│ ├── binary_scanner.py ← DWORD IP scan, resource string extraction
│ ├── blob_pipeline.py ← Multi-layer blob decode pipeline (v7.0+)
│ ├── cipher_engine.py ← ChaCha20/Salsa20/DES/Blowfish + format detection
│ ├── decoder_engine.py ← AES-CBC/ECB/CTR/GCM, RC4, base64, zlib
│ ├── dotnet_parser.py ← dnfile-based .NET assembly analysis
│ ├── elf_parser.py ← ELF binary parsing (Linux/IoT)
│ ├── entropy_scanner.py ← Shannon entropy + high-entropy region finder
│ ├── family_extractor.py ← Malware family config extractors
│ ├── ioc_extractor.py ← IOC aggregation and deduplication
│ ├── key_recovery.py ← Key candidate extraction + PBKDF2 derivation
│ ├── language_detector.py ← Compiler/language fingerprinting
│ ├── magic_detector.py ← File type identification
│ ├── pe_parser.py ← PE header, imports, sections, hashes
│ ├── ps_deobfuscator.py ← PowerShell/VBS/JS/BAT deobfuscation
│ ├── rc4_engine.py ← RC4 KSA detection + brute-force
│ ├── risk_engine.py ← Risk scoring + MITRE ATT&CK mapping
│ ├── script_analyzer.py ← Script-specific IOC and pattern analysis
│ ├── string_categorizer.py ← String classification into IOC buckets (v9.0)
│ ├── string_hunter.py ← ASCII/Unicode string extraction
│ ├── unpacker.py ← UPX auto-unpack + PE overlay + Rich header (v9.0)
│ ├── virustotal.py ← VT hash lookup
│ └── xor_engine.py ← XOR brute-force + known malware key table
│
├── detectors/ ← Specialized detection modules
│ ├── anti_analysis_detector.py ← Anti-debug/VM/sandbox detection
│ ├── packer_id.py ← Packer signature identification
│ └── yara_engine.py ← YARA rule engine (25+ bundled rules)
│
├── output/
│ └── reporter.py ← JSON/CSV/STIX report generation
│
├── web/
│ └── index.html ← Full SOC dashboard (single-file SPA)
│
├── tests/
│ └── create_test_samples.py ← Synthetic test sample generator
│
└── samples/
└── test/ ← Generated test samples go here
```
## 🎯 包含的 YARA 规则
RAPTOR 内置了 25+ 条生产级 YARA 规则,涵盖:
| 类别 | 家族 |
|---|---|
| **勒索软件** | WannaCry、Ryuk、Conti、LockBit、通用 |
| **RATs** | njRAT、AsyncRAT、DarkComet、QuasarRAT |
| **窃密程序** | RedLine、Vidar、通用浏览器窃密程序 |
| **Loaders** | Emotet、GuLoader |
| **C2 框架** | Cobalt Strike Beacon、Metasploit/Meterpreter |
| **凭证工具** | Mimikatz |
| **Web Shells** | PHP 通用、PowerShell Backdoor |
| **Packers** | UPX、Base64 Dropper |
| **键盘记录器** | 通用基于 Hook 的程序 |
将您自己的 `.yar` 文件放入 `yara_rules/` 目录——它们会被自动加载。
## 🔐 恶意软件家族配置提取
RAPTOR 可解密完整的恶意软件配置——不仅是检测,还包括真实的 C2 地址、端口、加密密钥、mutex 名称和安装路径:
| 家族 | 提取方法 | 您将获得 |
|---|---|---|
| **AsyncRAT / DCRat** | AES-256-CBC + PBKDF2-SHA1 (50,000 次迭代) | C2 主机、端口、mutex、AES 密钥、salt、安装路径、反分析标记、版本、组 |
| **njRAT (Bladabindi)** | 明文 / Base64 | C2、端口、活动 ID、mutex、安装名称 |
| **AgentTesla** | 字符串模式分析 | SMTP 凭证、FTP 凭证、C2 面板 URL |
| **Remcos** | RC4 加密的配置块 | C2、端口、mutex、键盘记录器路径、屏幕截图间隔 |
| **Cobalt Strike** | Beacon 配置 (XOR 0x69 + base64) | C2、Malleable C2 Profile、休眠时间、抖动、named pipe |
| **NanoCore** | 明文配置 + 插件列表 | C2、端口、构建 GUID、插件名称 |
| **QuasarRAT** | AES 加密的配置 | C2、端口、证书、mutex、安装目录 |
| **Formbook** | 字符串模式分析 | C2 域名、诱饵 URL |
## 📊 风险评分
RAPTOR 使用加权多信号评分引擎:
| 信号 | 最高分 |
|---|---|
| YARA CRITICAL 匹配 | +40 |
| YARA HIGH 匹配 | +25 |
| 可疑 API (HIGH) | 每个 +12 |
| 威胁指标 | +5–25 |
| 检测到加密钱包 | +20 |
| 反分析技术 | +2–12 |
| 高熵(加壳) | +10 |
| 扩展名不匹配 | +10 |
| 检测到 Packer | +8 |
| 分数 | 判定 |
|---|---|
| 75–100 | 🔴 恶意 |
| 50–74 | 🟠 可能恶意 |
| 25–49 | 🟡 可疑 |
| 0–24 | 🟢 低风险 |
## 📤 IOC 导出格式
| 格式 | 用例 |
|---|---|
| **CSV** | SIEM 接入、电子表格分析 |
| **STIX2** | 威胁情报共享 (MISP、ISACs、政府订阅源) |
| **JSON** | 完整原始报告、API 集成 |
## 🔒 安全处理真实恶意软件
推荐的工作流程:
```
1. Disable Windows Defender for your samples folder (Exclusions)
OR work inside an isolated VM (VirtualBox / VMware)
2. Download samples from trusted repos only:
- MalwareBazaar (bazaar.abuse.ch) — password: "infected"
- theZoo (github.com/ytisf/theZoo) — password: "infected"
3. Extract with 7-Zip using the password
7z e sample.zip -pinfected -o./extracted/
4. Drop the extracted binary into RAPTOR
→ All analysis is static — nothing executes
5. Share only the report output, never the binary
```
## 🗑 版本历史
### v9.0 — 当前版本
- **新增:** `core/unpacker.py` —— UPX 自动脱壳、PE overlay 检测、Rich header 解析
- **新增:** `core/string_categorizer.py` —— 将字符串分类到网络 / 文件系统 / 加密 / 命令 / 持久化 / 凭证 / C2 / mutex 桶中
- **新增:** 已知恶意软件 XOR 密钥表 —— 在暴力破解之前会尝试 AsyncRAT、NanoCore、QuasarRAT、Remcos、njRAT、Lokibot、Emotet 等
- **新增:** 并行引擎执行 —— 熵、XOR、RC4、AES、YARA、二进制扫描器并发运行
- **新增:** VirusTotal 哈希优先检查 —— 在任何繁重的分析之前,在 6% 进度时查询 VT
- **新增:** Triage 模式 (`?triage=1`) —— 跳过 blob pipeline,获得 5–15 秒的快速结果
- **新增:** 对解码后的 blob pipeline payload 进行 YARA 扫描
- **新增:** ssdeep 模糊哈希 + imphash 添加到所有 PE 报告中
- **修复:** AsyncRAT 配置解密 —— PBKDF2 密码、IV 来源和 AES 填充均已更正
- **修复:** blob pipeline 挂起 —— `generate_derived_keys` 组合爆炸(对数百个字符串执行 PBKDF2×10000)
- **修复:** blob pipeline 线程 —— 使用具有实际时间预算的线程替换了损坏的 `multiprocessing.Pool`
### v7.0
- 多层 blob 解码 pipeline (`core/blob_pipeline.py`)
- `core/cipher_engine.py` —— ChaCha20、Salsa20、DES、Blowfish、自定义加密支持
- `core/key_recovery.py` —— 全面的密钥提取和 PBKDF2 派生
- `core/ps_deobfuscator.py` —— PowerShell/VBS/JS/BAT 去混淆
- 带有 SSE 实时进度流传输的 Flask Web UI
- CyberChef 风格的 Decoder Workbench
- VirusTotal 集成
- 脚本去混淆钩子
### Pre-v7.0
- 核心 8 模块 CLI pipeline
- Web UI、风险评分、MITRE ATT&CK 映射、IOC 导出
- RC4 + AES 解密引擎
- 家族配置提取器(初始集)
- Rich 终端输出 + 扫描历史
## 🗺 路线图
- [x] 核心分析 pipeline(PE、熵、字符串、XOR、IOCs、YARA)
- [x] Web UI + SOC 仪表板
- [x] RC4 + AES + 多重加密解密引擎
- [x] VirusTotal 集成
- [x] 多层 blob pipeline
- [x] 家族配置提取 + 解密(AsyncRAT、Remcos、njRAT、AgentTesla、CobaltStrike...)
- [x] .NET assembly 分析
- [x] ELF / Linux 恶意软件支持
- [x] 自动 UPX 脱壳
- [x] 脚本去混淆(PS1、VBS、JS、BAT)
- [ ] 动态沙箱集成(Cuckoo / Cape)
- [ ] 文档分析器(PDF、Office 宏)
- ] 团队仪表板 + 案例管理
- [ ] Docker 部署
## ⚠ 免责声明
RAPTOR 专为**防御性安全目的**而构建——恶意软件分析、事件响应、威胁狩猎和安全研究。请勿将其用于协助创建、部署或混淆恶意软件。作者对滥用行为不承担任何责任。
## 📄 许可证
MIT License —— 可免费使用、修改和分发,但需注明出处。
## 🙏 构建基础
- [pefile](https://github.com/erocarrera/pefile) — PE 解析
- [yara-python](https://github.com/VirusTotal/yara-python) — YARA 规则引擎
- [capstone](https://www.capstone-engine.org/) — 反汇编引擎
- [dnfile](https://github.com/malwarefrank/dnfile) — .NET assembly 解析
- [pycryptodome](https://github.com/Legrandin/pycryptodome) — 密码学引擎
- [Flask](https://flask.palletsprojects.com/) — Web 服务器
- [Rich](https://github.com/Textualize/rich) — 终端输出
**RAPTOR** · 威胁运营与响应逆向分析平台
*为防御者构建。本地运行。*
标签:DAST, DNS 反向解析, 云安全监控, 云资产清单, 威胁情报, 安全运营, 开发者工具, 恶意软件分析, 扫描框架, 自动化分析, 跨站脚本, 逆向工具, 逆向工程, 静态分析