joan-bisbal/web3-smart-contract-auditor-cli
GitHub: joan-bisbal/web3-smart-contract-auditor-cli
一款用于检测 Solidity 和 Web3 WASM 智能合约安全漏洞的静态分析工具,支持重入攻击、访问控制缺陷等常见问题的自动化扫描与报告生成。
Stars: 0 | Forks: 0
# Web3 智能合约静态审计与漏洞扫描工具




生产级静态分析工具,用于检测 Solidity 和 Web3 WASM 智能合约中的安全漏洞、重入向量、未处理的返回值以及访问控制缺陷。
## 目录
- [架构概览](#architecture-overview)
- [漏洞检测矩阵](#vulnerability-detection-matrix)
- [快速入门与测试](#quick-start--testing)
- [代码使用示例](#code-usage-example)
- [许可证](#license)
## 架构概览
```
graph TD
Source[Solidity / WASM Source Code] -->|1. Parse Lines| Parser[AST & Pattern Parser]
Parser -->|2. Match Rule Taxonomy| Engine[Static Security Engine]
Engine -->|3. Calculate Risk & Line Index| Reporter[Audit Report Generator]
Reporter -->|4. Output JSON / Text Summary| Report[(Security Audit Finding)]
```
## 漏洞检测矩阵
| SWC ID | 漏洞名称 | 严重程度 | 描述 |
| :--- | :--- | :--- | :--- |
| `SWC-107` | 重入攻击 | `HIGH` | 在内部状态修改之前进行了外部调用 |
| `SWC-105` | 未受保护的 `tx.origin` | `HIGH` | 使用 `tx.origin` 进行身份验证容易受到钓鱼攻击 |
| `SWC-115` | 缺少访问控制 | `MEDIUM` | 修改状态的外部函数缺少访问修饰符 |
| `SWC-104` | 未检查的返回值 | `LOW` | 低级 `.call()` 或 `.send()` 的布尔返回值被忽略 |
## 快速入门与测试
### 安装说明
```
git clone https://github.com/joan-bisbal/web3-smart-contract-auditor-cli.git
cd web3-smart-contract-auditor-cli
```
### 运行单元测试套件
```
python -m unittest discover -s tests -p "test_*.py"
```
## 代码使用示例
```
from src.auditor import SmartContractAuditor
auditor = SmartContractAuditor()
source_code = """
pragma solidity ^0.8.0;
contract Vault {
mapping(address => uint) public balances;
function withdraw() external {
(bool success, ) = msg.sender.call{value: balances[msg.sender]}("");
balances[msg.sender] = 0;
}
}
"""
report = auditor.audit_code(source_code)
print(f"Total Vulnerabilities: {report['total_issues']}")
print(f"High Severity: {report['summary']['HIGH']}")
```
## 许可证
本项目基于 [MIT 许可证](LICENSE) 开源。
标签:AI工具, Python, Web3, 云安全监控, 安全专业人员, 无后门, 智能合约, 逆向工具, 静态分析