arkanzasfeziii/Smart-Contract-Security-Scanner
GitHub: arkanzasfeziii/Smart-Contract-Security-Scanner
Solidity 智能合约静态分析工具,在部署前检测安全漏洞并提供分级报告与修复建议。
Stars: 0 | Forks: 0
# 🔒 智能合约安全扫描器
[](https://python.org)
[](LICENSE)
[](https://soliditylang.org)
用于检测 Solidity 智能合约中安全漏洞的静态分析工具。专为开发者和安全审计人员构建,以便在部署前识别常见的弱点。
## ✨ 功能
- 🔍 **12+ 项漏洞检测**,包括:
- Reentrancy (SWC-107)
- tx.origin 滥用 (SWC-115)
- Integer overflow/underflow (SWC-101)
- 访问控制问题 (SWC-105)
- Timestamp dependence (SWC-116)
- 危险的 delegatecall (SWC-112)
- 未受保护的 selfdestruct (SWC-106)
- 未检查的外部调用
- 存在漏洞的编译器版本
- 📊 **严重性分类**:Critical、High、Medium、Low、Info、Gas Optimization
- 💡 **可操作的修复建议**:详细的缓解步骤 + OpenZeppelin 示例
- 📈 **丰富的控制台输出**:带有置信度评分的颜色编码结果
- 📤 **多种导出格式**:JSON、HTML 报告
- ⚡ **Gas Optimization 检测**(深度分析模式)
- 🔍 **SWC Registry 集成**:标准化的弱点分类
## 🚀 快速开始
### 前置条件
- Python 3.8+
- Solidity 项目目录或 `.sol` 文件
### 安装
```
# Clone repository(可选)
git clone https://github.com/your-username/smartcontractsecscan.git
cd smartcontractsecscan
# Create virtual environment(推荐)
python3 -m venv venv
source venv/bin/activate # Linux/MacOS
# OR
venv\Scripts\activate # Windows
```
基本用法
```
# 扫描单个 contract
python smartcontractsecscan.py contracts/MyToken.sol
# 扫描整个项目目录
python smartcontractsecscan.py ./contracts
# 深度分析(gas optimization + best practices)
python smartcontractsecscan.py ./contracts --deep
# 生成 JSON 报告
python smartcontractsecscan.py ./contracts --output report.json
# 生成 HTML 报告
python smartcontractsecscan.py ./contracts --output report.html
# 自定义 ignore patterns
python smartcontractsecscan.py ./src --ignore 'test' --ignore 'mock'
```
示例输出
```
┌──────────────────────────────────────────────────────────────┐
│ Scan Complete │
│ Path: ./contracts │
│ Duration: 2.34s │
│ Files: 12 | Contracts: 8 │
└──────────────────────────────────────────────────────────────┘
Summary:
┌──────────────────────┬────────┐
│ Severity │ Count │
├──────────────────────┼────────┤
│ CRITICAL │ 1 │
│ HIGH │ 3 │
│ MEDIUM │ 2 │
│ LOW │ 4 │
│ INFO │ 2 │
│ GAS OPTIMIZATION │ 5 │
└──────────────────────┴────────┘
Findings by File:
./contracts/Vault.sol (3 findings)
[CRITICAL] Line 45: Potential Reentrancy Vulnerability
Confidence: 70%
payable(recipient).transfer(amount);
SWC-107: Reentrancy
```
🔐 安全免责声明
此工具仅供教育和授权的安全测试目的使用。
❌ 请勿在未经明确许可的情况下,对您不拥有的合约使用此工具
❌ 请勿仅依赖静态分析来保障生产环境安全
✅ 务必结合以下措施:
专业的安全审计
运行时测试(Slither、Mythril、Echidna)
广泛的测试覆盖率(>95%)
主网部署前先在测试网部署
⚠️ 作者对未检测到的漏洞或滥用行为不承担任何责任
标签:Python, 云安全监控, 区块链安全, 无后门, 智能合约, 逆向工具, 静态分析