ingenious222/GhostTrace

GitHub: ingenious222/GhostTrace

GhostTrace 是一款结合 LLM Agent 与 Volatility 的半自动化内存取证平台,旨在加速无文件恶意软件的检测与威胁分析流程。

Stars: 0 | Forks: 0

# 🧠 GhostTrace **用于无文件恶意软件检测的半自动化内存取证工具** [![CI](https://github.com/your-org/GhostTrace/actions/workflows/ci.yml/badge.svg)](https://github.com/your-org/GhostTrace/actions) ## 架构 ``` User Prompt │ ▼ MemForensicAgent (ReAct Loop) ─── OpenAI / Ollama │ ↕ tool calls Tool Executor ├── volatility_runner (pslist, pstree, malfind, netscan, dlllist, cmdline, handles) ├── acquisition (verify_dump_integrity, get_dump_info) ├── process_inspector (detect_process_anomalies) ├── network_inspector (detect_suspicious_connections) ├── powershell_decoder (decode_powershell_commands, extract_iocs) ├── threat_scorer (score_threats → 0-100 / LOW-CRITICAL) ├── timeline_builder (build_attack_timeline) └── report_generator → PDF + HTML + JSON ``` ## 快速开始 ### 1. 设置环境 ``` # 克隆项目 cd "e:/New folder" # 创建虚拟环境 python -m venv .venv .venv\Scripts\activate # Windows # 或者:source .venv/bin/activate (Linux/Mac) # 安装依赖 pip install -r requirements.txt pip install -e . # 配置环境 copy .env.example .env # 编辑 .env:设置 OPENAI_API_KEY 和 VOLATILITY_PATH ``` ### 2. 运行交互模式 (REPL) ``` # 使用真实的内存转储 python -m cli.main interactive --dump "C:/evidence/memdump.mem" # Mock 模式(无需 VM/Volatility —— 演示模式) python -m cli.main interactive --mock ``` ### 3. 一次性分析 ``` python -m cli.main analyze \ --dump "C:/evidence/memdump.mem" \ --query "Perform complete forensic analysis and generate a PDF report" \ --output "./output" ``` ### 4. 验证 Dump 完整性 ``` python -m cli.main verify-dump "C:/evidence/memdump.mem" \ --hash "abc123...sha256hash" ``` ### 5. 可用的 CLI 命令 | 命令 | 描述 | |---------|-------------| | `interactive` | 基于 Rich 的 REPL 取证会话 | | `analyze` | 通过 LLM agent 进行一次性分析 | | `score` | 根据 artefacts JSON 评估威胁分数 | | `report` | 从已保存的会话生成报告 | | `verify-dump` | 验证 dump 完整性 (SHA-256) | ## 交互式 REPL 命令 | 命令 | 操作 | |---------|--------| | `!help` | 显示命令 | | `!status` | 会话统计信息 | | `!save` | 将会话保存为 JSON | | `!report` | 生成 PDF 取证报告 | | `!reset` | 开始新的调查 | | `!tools` | 列出所有取证工具 | | `!quit` | 退出 | ## 威胁评分模型 | 类别 | 权重 | 指标 | |----------|--------|-----------| | Malfind injections | 30 | 代码注入 / shellcode | | Encoded PowerShell | 20 | 无文件 payload 传递 | | Process anomalies | 20 | 进程镂空、伪造、孤儿进程 | | Network anomalies | 15 | C2 连接 | | DLL anomalies | 10 | 反射式注入 | | Handle anomalies | 5 | 权限提升 | | 分数 | 等级 | 操作 | |-------|-------|--------| | 0–30 | 🟢 低 | 监控 | | 31–65 | 🟡 中 | 调查 | | 66–89 | 🔴 高 | 立即遏制 | | 90–100 | 💀 严重 | 事件响应 | ## 配置 编辑 `.env`: ``` LLM_PROVIDER=openai # or: ollama OPENAI_API_KEY=sk-... LLM_MODEL=gpt-4o # 对于 Ollama(本地,无需 API key): LLM_PROVIDER=ollama OLLAMA_BASE_URL=http://localhost:11434 OLLAMA_MODEL=llama3 VOLATILITY_PATH=C:/volatility3/vol.py VOLATILITY_VERSION=vol3 # or vol2 MEMORY_DUMP_PATH= REPORT_OUTPUT_DIR=./output ``` ## 在没有 Volatility / API 的情况下运行(演示模式) ``` # 使用来自 tests/fixtures/ 的 fixture 数据 python -m cli.main interactive --mock ``` 这展示了完整的 pipeline —— 进程分析、评分、时间线、PDF 报告 —— 而无需任何真实的内存 dump 或 API 调用。 ## 开发 ``` # 运行测试 pytest tests/ -v --cov=. --cov-report=term-missing # Lint ruff check . # Type check mypy core/ tools/ cli/ reporting/ # 或者使用 Makefile make test make lint make mock # run in demo mode ``` ## 项目结构 ``` GhostTrace/ ├── cli/ # CLI entry point & REPL │ ├── main.py # Click commands │ ├── interactive.py # Rich REPL │ └── banner.py # ASCII banner ├── core/ # Agent engine │ ├── agent.py # ReAct loop (OpenAI/Ollama) │ ├── system_prompt.py # Investigator persona & protocol │ ├── tool_registry.py # JSON schema for all 20 tools │ └── tool_executor.py # Tool dispatch + error handling ├── tools/ # Forensic tool wrappers │ ├── volatility_runner.py │ ├── acquisition.py │ ├── process_inspector.py │ ├── network_inspector.py │ ├── powershell_decoder.py │ ├── threat_scorer.py │ └── timeline_builder.py ├── reporting/ # Report generation │ ├── report_generator.py │ ├── pdf_exporter.py # WeasyPrint + ReportLab │ └── templates/report.html ├── tests/ # Unit tests │ └── fixtures/ # Mock Volatility outputs ├── config/config.yaml ├── .env.example ├── requirements.txt └── .github/workflows/ci.yml ``` ## 支持的内存 Dump 格式 `.mem`, `.raw`, `.dmp`, `.vmem`, `.lime` ## 内存采集工具(外部) - **DumpIt**(Windows — 推荐) - **WinPMEM**(开源) - **FTK Imager** 在采集完成后,务必立即计算并记录 dump 的 SHA-256 哈希值,以保证监管链的完整性。
标签:AI风险缓解, DNS 反向解析, JARM, LLM Agent, OpenCanary, Petitpotam, 内存分析, 威胁情报, 开发者工具, 数字取证, 自动化应急响应, 自动化脚本, 逆向工具