zqwx-l/defi-exploit-pipeline
GitHub: zqwx-l/defi-exploit-pipeline
基于 701 个历史 DeFi 攻击事件构建的自动化智能合约漏洞模式匹配与攻击面分析流水线。
Stars: 0 | Forks: 0
# DeFi 漏洞利用流水线
用于基于 DeFiHackLabs 的 701 个历史漏洞利用,分析 DeFi 智能合约的自动化流水线。
## 使用方法
```
# 匹配 exploit database
python3 pipeline.py
# 深度扫描 + 全面分析
python3 pipeline.py --scan
# 从 DeFiHackLabs 重新提取 database
python3 pipeline.py --extract
# Top N 匹配
python3 pipeline.py --top 20
```
## 流水线流程
```
1. EXTRACT → Parse 701 .sol exploit files → JSON database
2. MATCH → Compare target against exploit patterns
3. DEEP SCAN → Extract attack surface features dari target
4. REPORT → Generate markdown report dengan findings
```
## 文件
```
defi-exploit-pipeline/
├── pipeline.py # Main entry point
├── scripts/
│ ├── extract_db.py # Extract metadata dari 701 exploit files
│ ├── extract_logic.py # Extract call logic dan code signatures
│ └── match_pattern.py # Match target against exploit patterns
├── data/
│ ├── exploit_database.json # 701 exploit metadata (896KB)
│ ├── exploit_logic_db.json # 701 exploit logic (402KB)
│ ├── EXPLOIT_DATABASE.md # Readable exploit index
│ └── PATTERN_REFERENCE.md # Pattern signatures reference
└── output/
└── _report.md # Generated reports
```
## 数据库统计
- 解析了 **701 个漏洞利用文件**
- **121 种独特攻击模式**
- 归类了 **15 种漏洞类型**
- 覆盖 **10 条区块链**(ETH、BSC、Arbitrum、Polygon 等)
## 漏洞类型
| 类型 | 数量 | 描述 |
|------|-------|-------------|
| flash_loan | 375 | 闪电贷滥用 |
| oracle_manipulation | 241 | 价格预言机操纵 |
| reentrancy | 105 | 重入攻击 |
| approval_abuse | 412 | 代币授权问题 |
| dex_manipulation | 74 | DEX 池操纵 |
| signature_abuse | 114 | 签名/许可滥用 |
| access_control | 57 | 缺乏访问控制 |
| logic_error | 71 | 逻辑/数学错误 |
## 输出示例
```
🔍 Analyzing: Morpho.sol
📝 Signature: FLASH_LOAN → ORACLE → CALLBACK
🎯 Top 5 matching exploit patterns:
1. UwuLend (2024-06) — Score: 0.983 — $19.3M
2. Agave (2022-03) — Score: 0.879 — $1.5M
3. Euler (2023-03) — Score: 0.75 — $196M
```
## 环境要求
- Python 3.10+
- DeFiHackLabs 仓库位于 `/root/DeFiHackLabs/`
## 研究基础
- [DeFiHackLabs](https://github.com/SunWeb3Sec/DeFiHackLabs) — 701 个漏洞利用 PoC 合集
- 基于历史漏洞利用的模式分析:UwuLend、Euler、BonqDAO、Agave 等
标签:DeFi, Homebrew安装, 区块链安全, 安全漏洞分析, 智能合约审计