ghstouch/smart-contract-auditor
GitHub: ghstouch/smart-contract-auditor
基于多 Agent 架构与 LLM 的 EVM 智能合约安全审计器,自动检测蜜罐、代理风险、隐藏铸造及重入等漏洞。
Stars: 0 | Forks: 0
# 智能合约审计 Agent
基于多 Agent 架构构建的 AI 驱动智能合约安全审计器。自动扫描 EVM 智能合约中的蜜罐模式、可疑的 proxy 配置、隐藏的 mint 函数以及常见的漏洞模式。
## 架构
```
┌─────────────────────────────────────────────────┐
│ Orchestrator Agent │
│ (Claude / MiMo / DeepSeek) │
│ Decomposes audit goals → coordinates subagents │
└────────────┬────────────────┬────────────────────┘
│ │
┌────────▼──────┐ ┌─────▼──────────┐
│ Scanner Agent │ │ Analysis Agent │
│ (EVM RPC + │ │ (LLM-powered │
│ Etherscan) │ │ pattern match) │
└────────┬──────┘ └─────┬──────────┘
│ │
┌────────▼───────────────▼────────────┐
│ Report Generator │
│ (Markdown / JSON / PDF output) │
└─────────────────────────────────────┘
```
## 功能
- **蜜罐检测**:识别允许买入但阻止/限制卖出的合约
- **Proxy 分析**:检测没有 timelock 的可升级 proxy、admin key 风险
- **隐藏 Mint**:查找可由 owner/admin 访问的特权 mint 函数
- **重入模式**:对常见重入漏洞进行静态分析
- **所有权风险**:标记过大的 owner 权限、缺乏放弃机制
- **多 LLM 支持**:使用 Claude、MiMo 或 DeepSeek 进行智能模式分析
- **批量扫描**:并行排队并扫描多个合约
- **报告生成**:生成带有风险评分的结构化 Markdown/JSON 审计报告
## 快速开始
```
# 安装依赖项
pip install -r requirements.txt
# 配置环境
cp .env.example .env
# 使用你的 API keys 编辑 .env
# 运行单个 contract audit
python -m auditor scan 0xContractAddress --chain ethereum
# 从文件批量扫描
python -m auditor batch contracts.txt --output reports/
# 生成总结报告
python -m auditor report reports/ --format markdown
```
## 支持的链
| 链 | RPC | 浏览器 |
|-------|-----|----------|
| Ethereum | `eth-mainnet` | Etherscan |
| Arbitrum | `arb-mainnet` | Arbiscan |
| Optimism | `op-mainnet` | Optimistic Etherscan |
| Base | `base-mainnet` | Basescan |
| BSC | `bsc-mainnet` | BscScan |
| Polygon | `polygon-mainnet` | Polygonscan |
## 风险评分
| 评分 | 级别 | 描述 |
|-------|-------|-------------|
| 90-100 | 严重 (CRITICAL) | 迫在眉睫的 rug pull 风险 — 切勿交互 |
| 70-89 | 高 (HIGH) | 存在重大安全隐患 |
| 40-69 | 中 (MEDIUM) | 潜在风险,建议审查 |
| 0-39 | 低 (LOW) | 未发现重大问题 |
## 技术栈
- **运行时**:Python 3.11+
- **LLM 提供商**:Claude (Anthropic)、MiMo (Xiaomi)、DeepSeek
- **区块链**:web3.py、Etherscan API
- **分析**:Slither(静态)、自定义模式匹配
- **输出**:Markdown、JSON、PDF(通过 WeasyPrint)
## 项目结构
```
smart-contract-auditor/
├── auditor/
│ ├── __init__.py
│ ├── agent.py # Main orchestrator agent
│ ├── scanner.py # EVM contract scanner
│ ├── analyzer.py # LLM-powered analysis
│ ├── rules.py # Detection rule engine
│ ├── report.py # Report generator
│ ├── config.py # Configuration management
│ └── chains.py # Multi-chain RPC config
├── examples/
│ ├── honeypot.sol # Example honeypot contract
│ ├── proxy_risk.sol # Example risky proxy
│ └── sample_report.md # Example audit report
├── tests/
│ ├── test_scanner.py
│ ├── test_analyzer.py
│ └── test_rules.py
├── .env.example
├── .gitignore
├── requirements.txt
└── README.md
```
## 许可证
MIT
标签:DLL 劫持, Web3安全, 人工智能, 多智能体, 大语言模型, 智能合约审计, 用户模式Hook绕过, 逆向工具