cognis-digital/mevscope

GitHub: cognis-digital/mevscope

一款链上 MEV 分析工具,通过重放交易历史归因三明治攻击等 MEV 行为并核算每笔交易的受害者损失。

Stars: 0 | Forks: 0

MEVSCOPE # MEVSCOPE ### 重放交易(tx)或地址历史,以归因三明治攻击、抢跑和尾跑 MEV 提取,并提供每笔交易的损失核算。 [![PyPI](https://img.shields.io/pypi/v/cognis-mevscope.svg?color=6b46c1)](https://pypi.org/project/cognis-mevscope/) [![CI](https://static.pigsec.cn/wp-content/uploads/repos/2026/06/08775916c7163522.svg)](https://github.com/cognis-digital/mevscope/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-mevscope mevscope scan . # → prioritized findings in seconds ``` ## 使用说明 —— 步骤指南 `mevscope` 重放 DEX 交换历史并归因三明治/抢跑 MEV,同时提供每笔交易的受害者损失核算。控制台脚本:`mevscope`(或 `python -m mevscope`)。 1. 从克隆中**安装**: pip install -e . 2. **扫描交换历史 JSON 文件**以检测三明治攻击: mevscope scan demos/01-basic/swaps.json 3. **读取输出** —— `--format json` 暴露了你可以通过管道传递的汇总数据: mevscope scan swaps.json --format json | jq '.total_victim_loss' 4. **基于 MEV 进行拦截** —— 如果检测到任何三明治攻击,`--fail-on-mev` 将以非零状态退出: mevscope scan swaps.json --fail-on-mev 退出码:`0` 正常,`1` 使用 `--fail-on-mev` 时检测到三明治攻击,`2` 输入错误。 5. **在 CI 中实现自动化** —— 在受保护的路由器测试固件中标记回归问题: - run: pip install -e . - run: mevscope scan fixtures/swaps.json --fail-on-mev ## 目录 - [为什么选择 mevscope?](#why) · [功能](#features) · [快速开始](#quick-start) · [示例](#example) · [架构](#architecture) · [AI 技术栈](#ai-stack) · [对比分析](#how-it-compares) · [集成](#integrations) · [随处安装](#install-anywhere) · [相关工具](#related) · [贡献指南](#contributing) ## 为什么选择 mevscope? 只需一条 CLI 命令即可得出“这个月我被三明治攻击了多少?”的答案 —— 量化后的受害者损失数据非常适合在 Crypto Twitter 上分享。 `mevscope` 具有单一用途、可脚本化且支持自托管:将其指向目标,即可获得你现有工作流程所使用的格式(表格 · JSON · SARIF)的优先排序结果,在 CI 中对其进行拦截,并允许代理通过 MCP 驱动它。
↑ 回到顶部
## 功能 - ✅ 从 Obj 加载交易(Swaps) - ✅ 加载交易(Swaps) - ✅ 检测三明治攻击 - ✅ 生成报告 - ✅ 支持 Linux/macOS/Windows 运行 · Docker · devcontainer - ✅ 提供 Python、JavaScript、Go 和 Rust 版本(`ports/`)
↑ 回到顶部
## 快速开始 ``` pip install cognis-mevscope mevscope --version mevscope scan . # scan current project mevscope scan . --format json # machine-readable mevscope scan . --fail-on high # CI gate (non-zero exit) ```
↑ 回到顶部
## 示例 ``` $ mevscope scan . [HIGH ] MEV-001 example finding (./src/app.py) [MEDIUM ] MEV-002 another signal (./config.yaml) 2 findings · risk score 5 · 38ms ```
↑ 回到顶部
## 架构 ``` flowchart LR IN[input] --> P[mevscope
analyze + score] P --> OUT[report] ```
↑ 回到顶部
## 从任何 AI 技术栈中使用 `mevscope` 与所有主流的 AI 使用方式实现了互操作: - **MCP 服务器** —— `mevscope mcp`(Claude Desktop、Cursor、Cognis.Studio、[uncensored-fleet](https://github.com/cognis-digital/uncensored-fleet)) - **兼容 OpenAI / JSON** —— 通过管道将 `mevscope scan . --format json` 传递给任何代理或 LLM - **LangChain · CrewAI · AutoGen · LlamaIndex** —— 一行代码即可将 CLI/JSON 封装为工具 - **CI / 脚本** —— 为非 AI 流水线提供退出码 + SARIF
↑ 回到顶部
## 对比分析 | | **Cognis mevscope** | EigenPhi | |---|:---:|:---:| | 支持自托管,无需账号 | ✅ | 视情况而定 | | 单一命令,零配置 | ✅ | ⚠️ | | 提供 CI 所需的 JSON + SARIF | ✅ | 视情况而定 | | MCP 原生(AI 代理) | ✅ | ❌ | | 多语言移植(JS/Go/Rust) | ✅ | ❌ | | 开源许可证 | ✅ COCL | 视情况而定 | *秉承 **EigenPhi / mev-inspect-py** 的精神,以 Cognis 的方式重新构建。遗漏了致谢?欢迎提交 PR。*
↑ 回到顶部
## 集成 可接入你的技术栈:用于代码扫描的 **SARIF**,适用于所有场景的 **JSON**,面向 AI 代理的 **MCP 服务器**(`mevscope mcp`),以及用于 SIEM/Slack/Jira 的 Webhook 转发器。详见 [`docs/INTEGRATIONS.md`](docs/INTEGRATIONS.md)。
↑ 回到顶部
## 安装 —— 各种方式,全平台支持 ``` pip install "git+https://github.com/cognis-digital/mevscope.git" # pip (works today) pipx install "git+https://github.com/cognis-digital/mevscope.git" # isolated CLI uv tool install "git+https://github.com/cognis-digital/mevscope.git" # uv pip install cognis-mevscope # PyPI (when published) docker run --rm ghcr.io/cognis-digital/mevscope:latest --help # Docker brew install cognis-digital/tap/mevscope # Homebrew tap curl -fsSL https://raw.githubusercontent.com/cognis-digital/mevscope/main/install.sh | sh ``` | Linux | macOS | Windows | Docker | 云平台 | |---|---|---|---|---| | `scripts/setup-linux.sh` | `scripts/setup-macos.sh` | `scripts/setup-windows.ps1` | `docker run ghcr.io/cognis-digital/mevscope` | [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)交易。 - [`rugradar`](https://github.com/cognis-digital/rugradar) —— 代币合约风险扫描器,在你盲目冲入(ape)之前检测蜜罐、隐藏的铸造/黑名单功能、所有者后门以及未锁定的流动性。 - [`storagelens`](https://github.com/cognis-digital/storagelens) —— 对跨代理升级的合约存储布局进行差异比对和解码,以捕获存储冲突和未初始化的存储槽 bug。 - [`sigsleuth`](https://github.com/cognis-digital/sigsleuth) —— 将原始 calldata 和 EIP-712 类型化数据解码为人类可读的意图,标记盲签和恶意的 permit/Permit2 payload。 **探索工具套件 →** [🗂️ 全部 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 开放协作许可证 (COCL) v1.0** 下提供源代码 —— 个人、内部评估、研究和教育用途免费;**商业 / 生产用途需要许可证** (licensing@cognis.digital)。详见 [LICENSE](LICENSE)。
Cognis Digital · Cognis Neural Suite 170+ 工具之一 · Making Tomorrow Better Today
标签:MEV分析, Python, Web3, 以太坊, 区块链, 可视化界面, 数据可视化, 无后门, 日志审计, 智能合约, 请求拦截, 逆向工具