cognis-digital/bytematch

GitHub: cognis-digital/bytematch

验证 EVM 链上已部署字节码与源码或 Foundry 构建产物是否一致,检测代理合约和实现合约的篡改与未经验证状态。

Stars: 0 | Forks: 0

BYTEMATCH # BYTEMATCH ### 验证部署在链上的 bytecode 是否与给定的源码/Foundry 构建匹配,检测未经验证或被篡改的代理合约及实现合约。 [![PyPI](https://img.shields.io/pypi/v/cognis-bytematch.svg?color=6b46c1)](https://pypi.org/project/cognis-bytematch/) [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/b35435c037163620.svg)](https://github.com/cognis-digital/bytematch/actions) [![License: COCL 1.0](https://img.shields.io/badge/License-COCL%201.0-2b6cb0.svg)](LICENSE) [![Suite](https://img.shields.io/badge/Cognis-Neural%20Suite-6b46c1.svg)](https://github.com/cognis-digital) *Web3 与智能合约安全 —— 链上安全与分析。*
``` pip install cognis-bytematch bytematch scan . # → prioritized findings in seconds ``` ## 使用说明 —— 逐步指南 `bytematch` 用于验证已部署的 EVM runtime bytecode 是否与构建产物匹配。 1. **安装**(从克隆的仓库或发布版): pip install -e . 2. **验证**已部署的 bytecode 与编译器产物(Hardhat/Foundry JSON、原始十六进制、文件,或使用 `-` 代表 stdin)的一致性: bytematch verify --deployed 0x6080... --artifact build/MyContract.json 或者直接比较两个原始十六进制数据块: bytematch verify --deployed deployed.hex --artifact-hex artifact.hex 3. **严格比较**,使用 `--strict` 参数以确保出现任何差异(包括 metadata/immutables)时即判定失败: bytematch verify --deployed 0x6080... --artifact build/MyContract.json --strict 4. **读取结果**,生成机器可读的 JSON 格式以供工具链使用: bytematch --format json verify --deployed 0x6080... --artifact build/MyContract.json 该命令在不匹配时会以非零状态退出,因此仅凭退出状态码即可作为 pipeline 的门控。 5. **在 CI 中自动化**(例如:部署后的供应链检查): - run: bytematch verify --deployed "$DEPLOYED_HEX" --artifact build/MyContract.json --strict ## 目录 - [为什么选择 bytematch?](#why) · [功能](#features) · [快速开始](#quick-start) · [示例](#example) · [架构](#architecture) · [AI stack](#ai-stack) · [对比](#how-it-compares) · [集成](#integrations) · [随处安装](#install-anywhere) · [相关项目](#related) · [贡献指南](#contributing) ## 为什么选择 bytematch? 去中心化的“这个合约是否真的与其代码仓库声称的一致”检查,可在 CI/CD 中运行 —— 保障链上代码的供应链完整性。 `bytematch` 具备单一用途、可脚本化且支持自托管:将其指向目标,即可通过您工作流中已有的格式(表格 · JSON · SARIF)获取优先排序的结果,将其作为 CI 的门控,并允许 agent 通过 MCP 进行驱动。
↑ 回到顶部
## 功能 - ✅ Keccak256 - ✅ 规范化 Bytecode - ✅ 拆分 Metadata - ✅ 剔除 Metadata - ✅ 提取 Metadata - ✅ 验证 - ✅ 加载 Artifact Runtime Bytecode - ✅ 验证 Artifact - ✅ 支持 Linux/macOS/Windows · Docker · devcontainer 运行 - ✅ 提供 Python、JavaScript、Go 和 Rust 移植版 (`ports/`)
↑ 回到顶部
## 快速开始 ``` pip install cognis-bytematch bytematch --version bytematch scan . # scan current project bytematch scan . --format json # machine-readable bytematch scan . --fail-on high # CI gate (non-zero exit) ```
↑ 回到顶部
## 示例 ``` $ bytematch scan . [HIGH ] BYT-001 example finding (./src/app.py) [MEDIUM ] BYT-002 another signal (./config.yaml) 2 findings · risk score 5 · 38ms ```
↑ 回到顶部
## 架构 ``` flowchart LR IN[binary / sample] --> P[bytematch
scan + match] P --> OUT[detections] ```
↑ 回到顶部
## 从任何 AI stack 中使用 `bytematch` 与所有主流的 AI 使用方式兼容互通: - **MCP server** — `bytematch mcp` (Claude Desktop, Cursor, Cognis.Studio, [uncensored-fleet](https://github.com/cognis-digital/uncensored-fleet)) - **兼容 OpenAI / JSON** — 将 `bytematch scan . --format json` 管道传递给任何 agent 或 LLM - **LangChain · CrewAI · AutoGen · LlamaIndex** — 一行代码即可将 CLI/JSON 封装为工具 - **CI / 脚本** — 为非 AI pipeline 提供退出状态码 + SARIF
↑ 回到顶部
## 对比 | | **Cognis bytematch** | Sourcify | |---|:---:|:---:| | 支持自托管,无需账户 | ✅ | 视情况而定 | | 单条命令,零配置 | ✅ | ⚠️ | | 适用于 CI 的 JSON + SARIF | ✅ | 视情况而定 | | MCP 原生支持 (AI agents) | ✅ | ❌ | | 多语言移植版 (JS/Go/Rust) | ✅ | ❌ | | 开源许可 | ✅ COCL | 视情况而定 | *秉承 **Sourcify** 的精神,以 Cognis 的方式重新塑造。遗漏了致谢?欢迎提交 PR。*
↑ 回到顶部
## 集成 可无缝接入您的技术栈:用于代码扫描的 **SARIF**,适用任何场景的 **JSON**,面向 AI agent 的 **MCP server**(`bytematch mcp`),以及用于 SIEM/Slack/Jira 的 webhook 转发器。详见 [`docs/INTEGRATIONS.md`](docs/INTEGRATIONS.md)。
↑ 回到顶部
## 安装 —— 各种方式,所有平台 ``` pip install "git+https://github.com/cognis-digital/bytematch.git" # pip (works today) pipx install "git+https://github.com/cognis-digital/bytematch.git" # isolated CLI uv tool install "git+https://github.com/cognis-digital/bytematch.git" # uv pip install cognis-bytematch # PyPI (when published) docker run --rm ghcr.io/cognis-digital/bytematch:latest --help # Docker brew install cognis-digital/tap/bytematch # Homebrew tap curl -fsSL https://raw.githubusercontent.com/cognis-digital/bytematch/main/install.sh | sh ``` | Linux | macOS | Windows | Docker | Cloud | |---|---|---|---|---| | `scripts/setup-linux.sh` | `scripts/setup-macos.sh` | `scripts/setup-windows.ps1` | `docker run ghcr.io/cognis-digital/bytematch` | [DEPLOY.md](docs/DEPLOY.md) (AWS/Azure/GCP/k8s) |
↑ 回到顶部
## 相关 Cognis 工具 - [`reentryx`](https://github.com/cognis-digital/reentryx) — 静态 + 符号执行检测器,用于标记 Solidity/Vyper 中的重入攻击、跨函数重入和只读重入路径,并输出用于 CI 门控的 SARIF 结果。 - [`forkfuzz`](https://github.com/cognis-digital/forkfuzz) — 主网分叉不变量模糊测试器,通过针对实时状态和有状态序列回放您的合约,旨在部署前破坏协议不变量。 - [`approvewarden`](https://github.com/cognis-digital/approvewarden) — 扫描任何钱包中危险的 ERC-20/721/1155 代币授权和无限额度,评估资金流失风险敞口并生成撤销(revoke)交易。 - [`mevscope`](https://github.com/cognis-digital/mevscope) — 回放交易或地址历史,以归因夹子攻击、抢跑和尾跑等 MEV 提取行为,并提供每笔交易的损失核算。 - [`rugradar`](https://github.com/cognis-digital/rugradar) — 代币合约风险扫描器,在您盲目投资(ape)前检测蜜罐、隐藏的 mint/黑名单函数、所有者后门以及未锁定的流动性。 - [`storagelens`](https://github.com/cognis-digital/storagelens) — 对跨代理升级的合约存储布局进行对比和解码,以捕获存储冲突和未初始化槽位的 bug。 **探索完整工具套件 →** [🗂️ 所有 170+ 工具](https://github.com/cognis-digital/cognis-neural-suite) · [⭐ awesome-cognis](https://github.com/cognis-digital/awesome-cognis) · [🔗 cognis-sources](https://github.com/cognis-digital/cognis-sources) · [🤖 uncensored-fleet](https://github.com/cognis-digital/uncensored-fleet) · [🧠 engram](https://github.com/cognis-digital/engram)
↑ 回到顶部
## 互操作性 `{}` 与包含 300+ 工具的 Cognis 套件有机结合 —— 统一的 JSON 输入/输出以及共享的 兼容 OpenAI 的 `/v1` 骨干网络。请参阅 **[INTEROP.md](INTEROP.md)** 获取 套件图谱、组合模式及参考技术栈。 ## 许可证 源码可见,基于 **Cognis Open Collaboration License (COCL) v1.0** —— 可免费用于个人使用、内部评估、研究和教育用途;**商业/生产环境使用需获取许可** (licensing@cognis.digital)。详见 [LICENSE](LICENSE)。
Cognis Digital · 170+ 款 Cognis Neural Suite 工具之一 · Cognis Neural Suite · 让明天在今天变得更美好
标签:Foundry, Web3, 一致性校验, 区块链安全, 可视化界面, 数据可视化, 日志审计, 智能合约, 请求拦截, 逆向工具