tejasprasad2008-afk/evidencechain

GitHub: tejasprasad2008-afk/evidencechain

面向 SANS SIFT Workstation 的自主取证调查 Agent,通过 21 个 MCP 工具和自我修正引擎实现对磁盘与内存证据的自动化分析、矛盾检测与置信度评分。

Stars: 0 | Forks: 0

# EvidenceChain **适用于 SANS SIFT Workstation 且具备自我修正功能的自主取证调查 Agent** EvidenceChain 是一个定制的 MCP 服务器,公开了 21 个类型化取证工具,用于自主事件响应。AI agent 通过 stdio 传输进行连接,并使用这些工具调查磁盘镜像和内存捕获文件。它内置了 4 轮自我修正引擎,能够检测过度推断、捕捉矛盾、评估置信度并规划重新调查——全程无需人工干预。 为 [SANS Find Evil! 黑客马拉松](https://findevil.devpost.com/)(2026 年 4 月至 6 月)而构建。 ## 架构 ![EvidenceChain — 自主取证调查流程](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/f56f282ecb224114.svg) ### 安全边界(架构层面,非基于提示) | 边界 | 执行方式 | |---|---| | 只读证据 | 代码中使用 `mount -o ro,loop,noatime` | | 路径白名单 | `PathValidator` 检查每个读/写路径 | | 命令黑名单 | `CommandGuard` 阻止 `rm`、`dd`、`curl`、`ssh`、`python` 等 | | 输出上限 | `OutputCap` 将每次工具响应截断为 100KB | | 无 Shell 访问权限 | 工具为类型化 MCP 函数,无 `execute_shell_cmd` | | 写入隔离 | 仅 `analysis/`、`reports/`、`audit/` 目录可写 | ## 工具(共 21 个) ### 磁盘分析 (9) | 工具 | 功能 | 证明内容 | |---|---|---| | `mount_evidence` | 以只读方式挂载 E01/dd/raw | -- | | `get_filesystem_timeline` | 通过 fls+mactime 获取 MAC 时间线 | 文件时间戳 | | `parse_mft` | MFTECmd 与 $SI 和 $FN 的比较 | 时间戳篡改检测 | | `parse_event_logs` | 带有事件 ID 过滤的 EvtxECmd | 安全事件 | | `parse_prefetch` | PECmd 执行时间戳 | **执行**(最多 8 次运行) | | `parse_amcache` | 带有 SHA1 的 AmcacheParser | **执行** + 哈希值 | | `parse_registry` | RECmd 持久化/配置 | 已配置的持久化 | | `extract_file` | 提取文件及 SHA-256 | 文件内容 | | `unmount_evidence` | 清理并卸载 | -- | ### 内存分析 (6) | 工具 | 功能 | 证明内容 | |---|---|---| | `memory_process_list` | pslist + psscan 双重扫描 | 运行中/隐藏进程 | | `memory_network_connections` | netscan + netstat | 网络连接 | | `memory_injected_code` | malfind (RWX 区域) | **暗示**代码注入 | | `memory_services` | svcscan | 服务配置 | | `memory_command_lines` | cmdline 提取 | 命令参数 | | `memory_dump_process` | 进程内存及字符串 | 深度分析 | ### 信息扩充 (4) | 工具 | 功能 | 来源 | |---|---|---| | `compute_hashes` | MD5/SHA1/SHA256 | 本地 | | `enrich_indicators` | 威胁情报查询 | VT, AbuseIPDB, MalwareBazaar, LOLBAS, OTX | | `yara_scan` | 模式匹配 | YARA 规则 | | `generate_super_timeline` | log2timeline + psort | Plaso | ### 自我修正与报告生成 (2) | 工具 | 功能 | |---|---| | `run_self_correction` | 4 轮引擎:验证、矛盾检测、置信度评分、重新调查规划 | | `generate_report` | 包含发现结果、MITRE 覆盖范围、时间线、审计跟踪的 Markdown + JSON 报告 | ## 自我修正引擎 该引擎在每批工具执行完毕后运行 4 轮: 1. **内联验证摘要** -- 聚合来自工具验证器的过度推断标志和时间戳篡改检测 2. **跨来源矛盾检测** -- 7 个检测器用于发现内部不一致性: - `TIMESTAMP_PARADOX` -- 跨工件时间戳冲突 - `EXECUTION_OVERCLAIM` -- 仅凭存在性证据即声称已执行(关键) - `GHOST_PROCESS` -- 内存中存在进程但无磁盘痕迹 - `TIMELINE_GAP` -- 可疑的事件日志空白(超过 6 小时且与日志清除关联) - `ATTRIBUTION_MISMATCH` -- 跨来源的哈希值冲突 - `ANTI_FORENSIC_INDICATOR` -- 时间戳篡改、日志清除、已知工具 - `PHANTOM_ARTIFACT` -- 幻觉捕获(关键) 3. **置信度评分** -- 基于证据权重的 0.0-1.0 评分: - 直接 (DIRECT) 证据 (0.90) > 佐证 (CORROBORATED) (0.80) > 间接 (CIRCUMSTANTIAL) (0.50) > 推断 (INFERRED) (0.30) - 自动确认得分 >= 0.75 的发现,标记 < 0.40 的结果以供审查 - 语义蕴含:执行 (EXECUTION) 蕴含存在 (PRESENCE) 4. **重新调查规划** -- 优先调用工具以解决未解决的矛盾 该流水线最多迭代 3 次或直到收敛(无新矛盾)为止。 ## 设置 ### 前置条件 - Python 3.10+ - SANS SIFT Workstation(用于获取完整的工具访问权限) ### 快速安装 (SIFT VM) ``` git clone evidencechain cd evidencechain bash install.sh ``` 安装程序将会: - 创建虚拟环境 - 安装依赖项 - 检查 SIFT 取证工具 - 运行冒烟测试 - 打印 MCP 配置 ### 手动安装 ``` git clone evidencechain cd evidencechain python3 -m venv .venv source .venv/bin/activate pip install -e ".[dev]" ``` ### MCP 配置 添加至你的 agent MCP 配置中: ``` { "mcpServers": { "evidencechain": { "command": "/path/to/evidencechain/.venv/bin/python3", "args": ["-m", "evidencechain"], "cwd": "/path/to/evidencechain/src", "env": { "EVIDENCE_BASE_DIR": "/cases", "VT_API_KEY": "your-key-here", "ABUSEIPDB_API_KEY": "your-key-here", "OTX_API_KEY": "your-key-here" } } } } ``` 威胁情报 API 密钥为可选项。LOLBAS 和 MalwareBazaar 无需密钥即可工作。 ## 试用(评委) 1. **下载 SIFT Workstation**,来自 sans.org/tools/sift-workstation 2. **安装 Protocol SIFT**:`curl -fsSL https://raw.githubusercontent.com/teamdfir/protocol-sift/main/install.sh | bash` 3. **克隆并安装 EvidenceChain**:`git clone && cd evidencechain && bash install.sh` 4. **将证据放入** `/cases/` 目录(磁盘镜像、内存捕获文件) 5. **配置你的 agent**,使用安装程序输出的 MCP 配置 6. **启动 agent** -- 它将自主分析证据 该 agent 将: - 挂载并解析磁盘工件 - 分析内存以查找隐藏进程和注入代码 - 通过威胁情报扩充指标 - 通过检测矛盾并重新调查来进行自我修正 - 生成结构化的 Markdown + JSON 报告 ## 运行测试 ``` # 所有 smoke tests python3 tests/test_block2_smoke.py # 10 tests — disk tools + validators python3 tests/test_block3_smoke.py # 12 tests — memory tools + validators python3 tests/test_block4_smoke.py # 55 tests — self-correction engine python3 tests/test_block5_smoke.py # 66 tests — threat intel enrichment python3 tests/test_block6_smoke.py # 74 tests — report generator python3 tests/test_block7_integration.py # integration tests # 完整 regression python3 -c " import subprocess, sys for t in ['tests/test_block2_smoke.py','tests/test_block3_smoke.py', 'tests/test_block4_smoke.py','tests/test_block5_smoke.py', 'tests/test_block6_smoke.py','tests/test_block7_integration.py']: r = subprocess.run([sys.executable, t], capture_output=True, text=True) print(f'{t}: {\"PASS\" if r.returncode == 0 else \"FAIL\"}')" ``` ## 项目结构 ``` evidencechain/ src/evidencechain/ server.py # MCP server entry point (21 tools) enums.py # 12 enums (ArtifactType, EvidenceSemantics, etc.) models.py # 11 dataclasses (EvidenceAtom, ForensicFinding, etc.) config.py # Configuration + security constants forensic_semantics.py # What each artifact PROVES vs CANNOT_PROVE security/ path_validator.py # Read/write path allowlists command_guard.py # Binary denylist output_cap.py # 100KB output truncation provenance/ evidence_store.py # Central atom/finding/contradiction store audit_logger.py # Append-only JSONL audit trail evidence_registry.py # Tool execution tracking tools/ base.py # Base tool executor disk.py # 9 disk analysis tools memory.py # 6 memory analysis tools enrichment.py # 4 enrichment tools validators/ base.py # Base validator timestamps.py # Cross-timestamp validation shimcache.py # ShimCache semantics (PRESENCE only) prefetch.py # Prefetch execution proof amcache.py # Amcache execution + hash mft.py # MFT timestomping detection evtx.py # Event log validation registry.py # Registry persistence validation memory.py # Memory artifact validation correction/ detectors.py # 7 contradiction detectors confidence.py # Evidence-weighted confidence scoring engine.py # 4-pass correction orchestrator threat_intel/ rate_limiter.py # Token bucket per-source limiter aggregator.py # Weighted consensus verdict sources/ base.py # Abstract source adapter virustotal.py # VirusTotal API v3 abuseipdb.py # AbuseIPDB v2 malwarebazaar.py # MalwareBazaar (free, no key) lolbas.py # 25 LOLBins knowledge base alienvault_otx.py # AlienVault OTX v1 knowledge/ forensic_kb.py # MITRE ATT&CK (30+), baselines, narratives report/ builder.py # ReportData assembly from evidence store generator.py # Jinja2 rendering to Markdown + JSON templates/ report.md.j2 # Markdown report template report.json.j2 # JSON report template tests/ test_block2_smoke.py # Disk tools tests test_block3_smoke.py # Memory tools tests test_block4_smoke.py # Self-correction tests test_block5_smoke.py # Threat intel tests test_block6_smoke.py # Report generator tests test_block7_integration.py # Full pipeline integration AGENTS.md # Agent configuration guide install.sh # One-command installer pyproject.toml # Package metadata LICENSE # MIT ``` ## 审计跟踪 每次工具执行都会以仅追加的 JSONL 格式记录到 `analysis/audit/` 中: - `executions.jsonl` -- 包含参数、持续时间、结果的 Tool 调用 - `findings.jsonl` -- 发现结果的创建与状态变更 - `contradictions.jsonl` -- 检测到的矛盾及受影响的发现结果 - `corrections.jsonl` -- 自我修正迭代与收敛情况 评委可以通过 `EvidenceAtom` 记录中的 `execution_id` 关联,将任何发现结果追溯至产生该结果的确切工具执行过程。 ## 许可证 MIT -- 请参阅 [LICENSE](LICENSE)。
标签:AI智能体, Amcache, E01, EDR, LLM Agent, MCP Server, MFT解析, Prefetch, SANS SIFT, SecList, 事件日志, 内存取证, 大语言模型工具, 子域名变形, 库, 应急响应, 数字取证, 数据提取, 时间轴分析, 注册表分析, 矛盾检测, 磁盘取证, 磁盘镜像分析, 网络安全, 置信度评分, 脆弱性评估, 自主智能体, 自动化取证, 自动化脚本, 自动化调查, 自我纠正, 逆向工具, 隐私保护, 黑客松项目, 黑灰产对抗