azizn9670/solmiko-audit
GitHub: azizn9670/solmiko-audit
一款基于 MiMo 模型构建的 AI 驱动 Solidity 智能合约安全审计工具,通过多 Agent 架构实现深度语义分析与经济模型风险检测。
Stars: 0 | Forks: 0
# SolMiKo Audit
**基于 MiMo 模型构建的 AI 驱动的智能合约安全审计工具。**
SolMiKo Audit 使用多步推理结合 MiMo-V2.5-Pro 来检测 Solidity 智能合约中的漏洞。与基于模式匹配的工具(Slither、Mythril)不同,SolMiKo 执行深度语义分析——理解合约意图、追踪执行路径,并识别静态分析器无法发现的复杂攻击向量。
## 为什么选择 SolMiKo?
| 功能 | Slither/Mythril | SolMiKo Audit |
|---|---|---|
| 模式匹配 | ✅ | ✅ |
| 语义理解 | ❌ | ✅ (MiMo 推理) |
| 多合约分析 | 有限 | ✅ 跨合约追踪 |
| 新型攻击向量 | ❌ | ✅ (0-day 检测) |
| 纯英文报告 | ❌ | ✅ |
| Gas 优化 | 基础 | ✅ AI 建议的重构 |
## 架构
```
┌─────────────────────────────────────────────────────────┐
│ Orchestrator │
│ (async pipeline manager) │
├─────────┬──────────┬──────────┬──────────┬──────────────┤
│ Parser │ Static │ Semantic │ Economic │ Report │
│ Agent │ Analyzer │ Analyzer │ Analyzer │ Generator │
│ (MiMo) │ (Slither │ (MiMo │ (MiMo │ (MiMo │
│ │ rules) │ V2.5) │ V2.5) │ V2.5-Pro) │
└─────────┴──────────┴──────────┴──────────┴──────────────┘
│ │ │ │ │
└──────────┴───────────┴──────────┴───────────┘
│
┌──────┴──────┐
│ FastAPI │
│ REST API │
└─────────────┘
```
### Agent
1. **Parser Agent** (MiMo-V2.5) — 解析 Solidity 源代码,提取 AST,识别合约结构、继承、状态变量、modifier 和 function signature。
2. **Static Analyzer** — 基于规则的检查(reentrancy 模式、unchecked 调用、tx.origin 使用、floating pragma、unsafe math)。将发现的结果反馈给语义分析器以提供上下文。
3. **Semantic Analyzer** (MiMo-V2.5-Pro) — 对合约逻辑进行深度推理。理解意图与实现之间的差异。检测:
- Reentrancy(跨函数、跨合约)
- 访问控制缺陷(缺少 modifier、错误的可见性)
- 整数溢出/下溢(0.8.0 之前版本)
- 闪电贷攻击向量
- Oracle 操纵可能性
- 抢跑漏洞
- 逻辑错误(错误的比较、off-by-one、状态混淆)
4. **Economic Analyzer** (MiMo-V2.5-Pro) — Token 经济学分析:
- 无限制铸造风险
- 手续费操纵向量
- LP 耗尽场景
- 治理攻击面
- MEV 提取机会
5. **Report Generator** (MiMo-V2.5-Pro) — 将所有发现整合为结构化报告,包含严重性评级(Critical/High/Medium/Low/Informational)、概念验证攻击场景和推荐的修复方案。
### Token 使用量
- 小型合约(约 200 行):每次审计约 150K token
- 中型合约(约 500 行):每次审计约 400K token
- 复杂的 DeFi 协议(约 2000 行):每次审计约 1.5M token
- 每天 100 次审计:约 60M token/天 → 需要 MiMo Max 套餐
## 快速开始
```
# 安装
pip install -r requirements.txt
# 审计合约文件
python -m solmiko audit contracts/Token.sol
# 审计 Etherscan 上的已验证合约
python -m solmiko audit --etherscan 0x1234...abcd --chain ethereum
# 使用特定 severity 过滤器进行审计
python -m solmiko audit contracts/Vault.sol --min-severity high
# 启动 API server
uvicorn api.main:app --host 0.0.0.0 --port 8000
```
## API 用法
```
# 通过 API 审计
curl -X POST http://localhost:8000/api/v1/audit -H "Content-Type: application/json" -d '{"source": "pragma solidity ^0.8.0;\ncontract Token { ... }"}'
# Response
{
"audit_id": "aud_20260521_001",
"contract": "Token",
"findings": [
{
"id": "SMK-001",
"severity": "critical",
"title": "Reentrancy in withdraw()",
"description": "External call to msg.sender before state update...",
"location": {"file": "Token.sol", "line": 45},
"proof_of_concept": "Attack contract calls withdraw() in receive()...",
"recommendation": "Use ReentrancyGuard or checks-effects-interactions pattern",
"confidence": 0.95
}
],
"gas_optimizations": [...],
"overall_risk": "high",
"token_usage": {"input": 45000, "output": 12000}
}
```
## 支持的链
- Ethereum (mainnet, Goerli, Sepolia)
- BNB Smart Chain
- Polygon
- Arbitrum
- Optimism
- Base
- 任何兼容 EVM 的链(通过自定义 RPC)
## 技术栈
- **Python 3.11+** 支持 async/await
- **MiMo-V2.5 / MiMo-V2.5-Pro** 用于 AI 推理(通过 9router)
- **FastAPI** 用于 REST API
- **web3.py** 用于链上合约获取
- **Slither** 集成,用于静态分析基线
- **Solidity parser** (solc-select) 用于 AST 提取
## 许可证
MIT
标签:AI大模型, Solidity, Web3安全, 云安全监控, 智能合约审计, 逆向工具, 静态分析