Raptor 是一个用于审计区块链生态系统(合约、协议等)的框架。
Raptor 提供了结构化的方法和工具,用于识别智能合约和区块链协议中的安全漏洞。该框架帮助审计人员一致地记录发现,并为多个审计平台生成报告。
# 安装最新稳定版(推荐)
curl -sSL https://raw.githubusercontent.com/calvin-kimani/raptor/main/install.sh | bash
# 安装特定版本
curl -sSL https://raw.githubusercontent.com/calvin-kimani/raptor/main/install.sh | bash -s -- v0.1.0
curl -sSL https://raw.githubusercontent.com/calvin-kimani/raptor/main/install.sh | bash -s -- 0.1.0
# 最新稳定版
git clone https://github.com/calvin-kimani/raptor.git /tmp/raptor-install
bash /tmp/raptor-install/install.sh
rm -rf /tmp/raptor-install
# 特定版本
git clone https://github.com/calvin-kimani/raptor.git /tmp/raptor-install
bash /tmp/raptor-install/install.sh v0.1.5
rm -rf /tmp/raptor-install
然后重启你的 shell 或运行:
source ~/.bashrc # 或 ~/.zshrc (zsh)
验证安装:
raptor --version
# 更新到最新稳定版
raptor update
# 更新到特定版本
raptor update v0.2.5
raptor update 0.2.5
# 升级到最新主版本
raptor upgrade
# 升级到特定主版本
raptor upgrade v1.0.0
# 降级到先前版本
raptor downgrade v0.1.0
# 列出所有可用版本
raptor version --list
# 显示当前版本
raptor version --current
raptor --version
raptor/
├── bin/ # CLI 可执行文件和模块
│ ├── raptor # 主 Raptor CLI 可执行文件
│ └── cli/ # CLI 模块代码
│ ├── __init__.py # 版本信息
│ ├── config.py # 配置管理
│ ├── finding.py # 发现管理
│ ├── git.py # Git 仓库管理
│ ├── init.py # 项目初始化
│ ├── plugin_lock.py # 插件锁文件管理
│ ├── plugin_manager.py # 插件发现与安装
│ ├── raptor.py # 主 CLI 逻辑
│ ├── report.py # 报告生成
│ ├── update.py # 版本管理
│ └── version_utils.py # 版本解析与比较
├── scripts/ # 用户自定义脚本目录
├── schemas/ # 报告模板和发现 schema
│ ├── reports/
│ │ ├── sherlock-report.yml # Sherlock 格式模板
│ │ ├── code4rena-report.yml # Code4rena 格式模板
│ │ └── codehawks-report.yml # CodeHawks 格式模板
│ └── findings/
│ └── finding-schema.json # 发现的 JSON schema
├── CONFIGURATION.md # 配置指南
├── CONTRIBUTING.md # 贡献指南
├── install.sh # 安装脚本
├── raptor.toml # 框架配置
└── README.md # 本文件
Raptor 支持为多个审计平台生成报告:
每个平台都有特定的格式要求。Raptor 将发现以结构化 JSON 格式存储,并转换为每个平台对应的 Markdown 格式。
模板位置:
~/.raptor/schemas/reports/<project>/audits/reports/.templates/raptor.toml 配置关于添加自定义报告格式,请参阅 CONFIGURATION.md。
Raptor 提供一个命令行界面用于管理审计项目:
# 初始化新的审计项目
raptor init my-audit
# 强制覆盖现有目录
raptor init my-audit --force
# 初始化时克隆仓库(默认为浅克隆)
raptor init --git-url https://github.com/user/repo.git
# 克隆多个仓库并带完整提交历史
raptor init --git-url URL1 URL2 --commit
# 向现有项目添加仓库(默认为浅克隆)
raptor git add https://github.com/user/repo.git
# 添加多个仓库并带完整历史
raptor git add URL1 URL2 --commit
# 列出 src/ 中的所有仓库
raptor git list
# 更新所有仓库
raptor git update
# 更新特定仓库
raptor git update repo1 repo2
# 移除仓库
raptor git remove repo-name
# 创建新发现(以 JSON 存储)
raptor finding --new "攻击者将从质押者那里抽走资金" --severity HIGH
# 创建发现并立即生成报告
raptor finding --new "withdraw 函数中的重入攻击" --severity CRITICAL --report sherlock code4rena
# 为所有发现生成报告(默认格式:sherlock)
raptor report
# 以特定格式生成报告
raptor report --format sherlock code4rena codehawks
# 为特定发现生成报告
raptor report --format sherlock --finding HIGH-reentrancy-attack
关键特性:
--git-url 克隆仓库,或使用 raptor git 命令管理--depth 1 克隆仓库以加快下载速度Raptor 支持可扩展的插件架构,具有自动依赖管理和多版本支持。
# 列出所有可用插件
raptor plugins list
raptor plugins -l
# 安装插件到项目(.plugins/)
raptor plugins install solidity-parser
# 全局安装插件(~/.raptor/bin/cli/plugins/)
raptor plugins install solidity-parser --global
raptor plugins -i solidity-parser -g
# 安装多个插件
raptor plugins install parser-plugin graph-plugin
# 强制重新安装
raptor plugins install solidity-parser --force
raptor plugins -i solidity-parser -f
# 检查插件状态
raptor plugins status solidity-parser
Raptor 允许同一插件的多个版本并行安装:
# 首次安装(成为活动版本)
raptor plugins install solidity-parser
# 安装到:.plugins/solidity-parser/1.0.0/
# 安装不同版本(先前版本保持活动)
raptor plugins install solidity-parser
# 安装到:.plugins/solidity-parser/1.1.0/
# 列表显示所有版本
raptor plugins list
# 输出:
# solidity-parser [Project] v1.0.0(2 个版本)
# 版本:v1.0.0*, v1.1.0
# 切换活动版本
raptor plugins switch solidity-parser 1.1.0
# 输出:✓ 已将 'solidity-parser' 从 v1.0.0 切换到 v1.1.0
已安装的插件在 .plugins.lock 中记录:
在 raptor.toml 中添加插件:
[plugins.my-plugin]
url = "https://raw.githubusercontent.com/user/repo/main/plugin/install.py"
version = ">=1.0.0" # 可选版本约束
description = "我的自定义插件"
# 或使用本地路径
[plugins.local-plugin]
url = "/path/to/plugin"
# 或相对路径
url = "../my-plugins/analyzer"
版本约束:
"1.0.0" 或 "@1.0.0" - 精确版本">=1.0.0" - 最低版本">1.0.0" - 大于版本"<=2.0.0" - 最高版本"<2.0.0" - 小于版本raptor init my-audit 初始化新的审计项目raptor git add https://github.com/user/repo.git 克隆目标合约仓库raptor finding --new "标题" --severity HIGH 记录发现raptor report --format sherlock code4rena 生成平台特定报告详细配置指南请参阅 CONFIGURATION.md。
请阅读我们的贡献指南。
请在所有交互中保持尊重和专业。我们都在这里共同学习和改进项目。
根据 Apache License(版本 2.0)或 [MIT License](./LICENSE-MIT)许可,您可任选其一。
除非您明确声明,否则根据 Apache-2.0 许可证定义,您有意提交以包含在这些 crate 中的任何贡献,均应按照上述双重许可方式处理,不附加任何额外条款或条件。
此框架仅供教育目的和授权安全测试使用。在进行安全审计之前,请始终获得适当授权。