dyno-dr/single-agent-blockchain-investigator

GitHub: dyno-dr/single-agent-blockchain-investigator

基于 LangGraph 与 Gemini AI 驱动的以太坊钱包自主取证系统,提供 Rugpull 预警、资金溯源和批量分析能力。

Stars: 1 | Forks: 0

System Workflow # 🕵️ 单 Agent 区块链调查器 **由 LangGraph 与 Gemini AI 驱动的下一代自主取证系统** [![Python 3.12+](https://img.shields.io/badge/Python-3.12+-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://python.org) [![FastAPI](https://img.shields.io/badge/FastAPI-0.115-009688?style=for-the-badge&logo=fastapi&logoColor=white)](https://fastapi.tiangolo.com) [![LangGraph](https://img.shields.io/badge/LangGraph-0.2-6B48FF?style=for-the-badge)](https://langchain-ai.github.io/langgraph/) [![Gemini](https://img.shields.io/badge/Gemini-2.0_Flash-4285F4?style=for-the-badge&logo=google&logoColor=white)](https://deepmind.google/technologies/gemini/) *即将推出的多 Agent 区块链取证框架的 Agent Zero。*


## 🌟 核心创新 ### 🧠 自主 LangGraph Pipeline 采用最先进的 6 节点 LangGraph 架构,利用 **Google 的 Gemini 2.0 Flash**。该 Agent 能够动态地: 1. 使用原始 Etherscan 数据对目标钱包进行**画像**。 2. **规划**确定性的追踪策略。 3. 使用 7 种确定性取证算法(例如,*High Fan-Out*、*Dormant Activation*、*Layering*)**检测**异常。 4. 将海量的状态历史**压缩**至上下文安全的报告边界内,确保 LLM 绝不会因上下文耗尽而产生幻觉。 ### 🛑 部署前 Rugpull 分诊 为什么要等到流动性池被抽干?**Rugpull Engine** 能够根据恶意合约部署者的*准备*行为来识别他们。 * **无试运行:** 标记那些未经 testnet 验证直接部署到 mainnet 的部署者。 * **快速爆发与即时克隆:** 识别垃圾合约的部署模式。 * **所有权转移:** 标记立即放弃所有权或可疑的权限交接。 ### 🕸️ 资金溯源图谱(联合体猎手) 这是我们取证工具箱中的一个强大新功能。恶意行为者极少单独行动——他们是由脚本化操作的联合体提供资金的。 我们的 **Funding Provenance Engine** 在 SQLite 中构建本地化的 `FunderGraph`,用于: * 提取确切的 **Centralized Exchange (CEX)** 或 **Mixer** 来源。 * 计算资金间隔时间的 **Coefficient of Variation (CV)**,从数学上证明钱包何时是由自动化脚本而非人类提供资金的。 * 遍历深层的多跳图谱,揭露支持欺诈部署的隐藏金融网络。 ### 📊 高级批量分析 研究人员可以同时评估数百个钱包。内置的 **Advanced Batch Analyzer** 利用 Pandas 和 Seaborn 自动生成精美、可直接用于发表的威胁评分分布、裁决细分以及触发规则频率的可视化图表。 ### 🎨 惊艳的 Glassmorphism 控制面板 无聊的终端输出已成过去。本项目自带**精美的 Vanilla JS 与 HTML5 Web 界面**。采用时尚的暗黑模式、glassmorphic 设计以及实时轮询——让您能够实时观察 Agent 在调查过程中的推理过程。
## 🏗️ 系统架构 ``` graph TD User([🕵️ User / Frontend]) -->|REST API| FastAPI subgraph LangGraph AI Agent FastAPI --> Planner[🧠 Gemini Planner] Planner --> Profiler[📊 Etherscan Profiler] Profiler --> Scorer[🧮 Trace Scorer] Scorer --> Detector[🚨 Anomaly Detector] Detector --> Reporter[📝 Gemini Reporter] Reporter --> Memory[(💾 SQLite Memory)] end subgraph Forensic Engines Detector -.-> Rugpull[🛑 Rugpull Triage Engine] Rugpull -.-> Provenance[🕸️ Funding Provenance Graph] Provenance -.-> Rules[⚖️ 7 Deterministic Rules] end ```
## 🚀 快速入门指南 **1. 克隆与设置** ``` git clone https://github.com//single-agent-blockchain-investigator.git cd single-agent-blockchain-investigator python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate pip install -r requirements.txt ``` **2. 配置环境** ``` cp .env.example .env ``` *将您的 `ETHERSCAN_API_KEY` 和 `GOOGLE_API_KEY` 添加到 `.env` 文件中。* **3. 启动后端** ``` uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000 ``` **4. 启动精美 UI** 只需在您最喜欢的 Web 浏览器中打开 `frontend/index.html`。无需复杂的 Node.js 构建步骤!输入钱包地址,让 Agent 完成繁重的工作。
## 🔬 分析与研究工具 对于数据科学家和区块链研究人员,该框架包含了强大的基准测试实用工具: **运行带有溯源追踪的完整数据集:** ``` python test_full_dataset.py --fetch ``` **生成可视化分析 (Seaborn/Pandas):** ``` python advanced_batch_analyzer.py ``` *自动生成 `analysis_verdicts.png`、`analysis_rules.png` 和 `analysis_scores.png`,精美地可视化 Agent 在批处理中的性能表现。* **通过 CLI 测试 LangGraph 引擎:** ``` python test_langgraph.py 0xYourWalletAddressHere ```
## 🛣️ 路线图 - **阶段 1** ✅ 基础设施(FastAPI、DB、Logging) - **阶段 2** ✅ 区块链数据层(Etherscan、Normalizer) - **阶段 3** ✅ Agent 层(LangGraph pipeline、7 条取证规则) - **阶段 4** ✅ 部署前 Rugpull 与资金溯源图谱 - **阶段 5** ✅ Glassmorphism 前端 UI - **阶段 6** 🔲 Agent 思考过程的 WebSocket 实时流 - **阶段 7** 🔲 多 Agent 扩展(AML 合规 Agent、Neo4j 知识图谱 Agent)
## 📚 学术与研究背景 本架构专为 **Multi-Agent 区块链取证研究项目** 从零开始设计,优先考虑可解释人工智能 (XAI) 而非黑盒预测。每一条发现都需要遵循严密的 `Observation → Evidence → Reasoning` 逻辑链。 **如果您在研究中使用了本框架,请引用:** ``` @software{blockchain_investigator_2025, title = {Single-Agent Blockchain Investigator}, author = {Dyno Dr}, year = {2025}, url = {https://github.com/dyno-dr/single-agent-blockchain-investigator} } ```
MIT License
为研究而生。为扩展性而设计。多 Agent 未来的 Agent Zero。
标签:AI智能体, AV绕过, DLL 劫持, FastAPI, Python, 以太坊, 区块链取证, 大语言模型, 无后门, 诈骗检测, 逆向工具