sjkim1127/Nexuscore_MCP
GitHub: sjkim1127/Nexuscore_MCP
面向 AI 驱动恶意软件分析的 MCP 服务器,通过 Frida 动态插桩和会话式调试,让大语言模型能够实时分析、脱壳和逆向逃避型恶意软件。
Stars: 13 | Forks: 1
# NexusCore MCP
   
**English** | **[한국어](README_KR.md)**
**NexusCore MCP** 是一个专为 **AI 驱动的动态恶意软件分析** 设计的高级 **Model Context Protocol (MCP)** 服务器。它填补了像 Claude/GPT-4 这样的大语言模型 (LLM) 与底层系统检测之间的空白,使 AI Agent 能够实时主动地调试、检查和分析逃避型恶意软件。
## 📑 目录
- [架构](#-architecture)
- [功能与工具](#-features--tools)
- [前置条件](#-prerequisites)
- [快速开始](#-quick-start-zero-to-hero)
- [AI 集成指南](#-ai-integration-guide-claude-desktop--cursor)
- [使用示例](#-usage-examples)
- [工具参考](#-tool-reference)
- [分析场景](#-analysis-scenario-cracking-themida)
- [故障排除](#-troubleshooting)
- [免责声明](#️-disclaimer)
## 🏗️ 架构
```
graph TD
A["AI Agent (Claude/Cursor)"] -- "MCP Protocol (Stdio)" --> B["NexusCore MCP Server"]
subgraph "Core Analysis Engine"
B -- "Persistent DB" --> C[("Sled Cache / Job Queue")]
B -- "Large Data" --> D["StreamManager (Dumps)"]
B -- "Observability" --> E["OpenTelemetry (Jaeger)"]
end
subgraph "SOTA Analysis Tools"
B -- "Micro-Emu" --> F["Unicorn Engine"]
B -- "Ref Bridge" --> G["Ghidra/IDA/x64dbg"]
B -- "Py Sandbox" --> H["AI Decryptor Tester"]
B -- "Self-Correction" --> I["YARA Verifier"]
end
subgraph "Host OS (Virtualized)"
B -- "Inject" --> J["Frida Engine (Stealth)"]
B -- "API" --> K["External (DIE, Capa, PE-Sieve)"]
end
```
## 🚀 功能与工具
### 🌟 业界顶尖 (SOTA) 能力
| 工具 | 描述 | 创新 |
|------|-------------|------------|
| **`micro_emulate`** | 执行隔离的代码片段/函数。 | **零执行分析** |
| **`sync_reversing_data`**| 将 AI 发现直接同步到 Ghidra/IDA。 | **实时工具同步** |
| **`test_decryptor`** | 用于 AI 生成的 Python 解密器的安全沙箱。 | **自定义逻辑逆向** |
| **`verify_yara`** | 自动针对样本验证 YARA 规则。 | **自我修正循环** |
| **`read_memory_chunk`**| 分块处理 GB 级别的内存转储。 | **上下文窗口优化** |
### 🛡️ 恶意软件分类与动态分析
| 工具 | 描述 | 关键技术 |
|------|-------------|----------|
| **`spawn_process`** | 使用隐蔽脱壳机以 **挂起状态** 生成恶意软件。 | Frida |
| **`api_monitor`** | 监控 Windows API 调用(注册表、网络、文件)。 | Frida |
| **`dump_ssl_keys`** | Hook 库以转储用于 HTTPS 解密的密钥。 | Frida |
| **`generate_yara`** | 自动生成初始 YARA 签名。 | Native |
| **`scan_pe_sieve`** | 检测进程镂空和 DLL 注入。 | PE-Sieve |
| **`die_scan` / `capa_scan`**| 使用 **Sled 缓存** 进行高速静态分析。 | DIE / CAPA |
### 🔧 基于会话的调试 (`src/tools/malware/debug/`)
| 工具 | 描述 |
|------|-------------|
| **`session_start`** | 启动持久化 cdb.exe 调试会话(无头模式)。 |
| **`session_command`** | 向活动会话发送单条命令。 |
| **`session_batch`** | 一次发送多条命令。 |
| **`session_end`** | 终止调试会话。 |
| **`debug_help`** | 常用 cdb.exe 命令参考。 |
### 🗃️ Frida 会话管理 (`src/tools/common/frida_session/`)
| 工具 | 描述 |
|------|-------------|
| **`frida_session_create`** | 创建持久化 Frida 会话。 |
| **`frida_session_inject`** | 向现有会话注入 JS 脚本。 |
| **`frida_session_messages`** | 获取从 hook 收集的消息。 |
| **`frida_session_destroy`** | 释放会话资源。 |
### 📊 系统与指标
| 工具 | 描述 |
|------|-------------|
| **`scan_persistence`** | 扫描注册表 Run 键和启动文件夹。 |
| **`inspect_gui`** | 提取窗口标题和类名。 |
| **`get_metrics`** | 返回性能指标(缓存统计、时间)。 |
### ⚡ 性能优化
- **SHA256 缓存**: Die/Capa/Floss 结果按文件哈希缓存(1小时 TTL)
- **批量缓冲**: Frida IPC 批量处理,开销减少 10 倍
- **异步 I/O**: 使用 `spawn_blocking` 进行文件操作
- **标准化 JSON**: 统一的响应格式,包含时间元数据
## 📋 前置条件
在开始之前,请确保您具备:
### 系统要求
- **操作系统**: Windows 10/11 (x64) - 最好是干净的 **虚拟机** (VirtualBox/VMware)
- **内存**: 建议 4GB+
- **磁盘空间**: 5GB+ 用于工具和依赖项
### 必备软件(由安装脚本自动安装)
- [Chocolatey](https://chocolatey.org/) - 包管理器
- [Rust](https://www.rust-lang.org/) (1.70+) - 编译器工具链
- [Visual C++ Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) - MSVC 链接器
- [Python 3.8+](https://www.python.org/) - 用于某些分析工具
- [Git](https://git-scm.com/) - 版本控制
### 分析工具(由安装脚本自动下载)
- **Detect It Easy (DIE)** - 加壳器/编译器检测
- **CAPA** - 能力分析
- **FLOSS** - 字符串提取
- **Sysinternals Suite** - 进程实用工具
### 可选(用于完整功能)
- **CAPEv2 Sandbox** - 远程恶意软件提交(自托管或公共实例)
- **Frida** - 动态插桩(自动配置)
## ⚡ 快速开始 (从零到精通)
### 步骤 1: 克隆仓库
```
git clone https://github.com/sjkim1127/Nexuscore_MCP.git
cd Nexuscore_MCP
```
### 步骤 2: 自动化环境设置
我们提供了一个 **一站式 PowerShell 脚本** 来配置您的整个分析环境。
在 PowerShell 中 **以管理员身份运行**:
```
Set-ExecutionPolicy Bypass -Scope Process -Force
.\scripts\setup_tools.ps1
```
此脚本将:
- ✅ 安装 Chocolatey 包管理器
- ✅ 安装 Rust、Python、Git、7-Zip 和 Visual C++ Build Tools
- ✅ 下载 DIE、CAPA、FLOSS 和 Sysinternals 工具到 `.\bin\`
- ✅ 将工具添加到您的系统 PATH
**⏱️ 预计时间**: 10-15 分钟(取决于网速)
**安装完成后**,重启终端以应用 PATH 更改。
### 步骤 3: 配置 (`.env`)
在根目录创建一个 `.env` 文件:
```
# .env - 配置文件
CAPE_API_URL=http://192.168.1.100:8000 # Your CAPEv2 instance (optional)
CAPE_API_TOKEN=your_token_here # API token if required (optional)
RUST_LOG=info # Log level (trace, debug, info, warn, error)
```
### 步骤 4: 构建 NexusCore MCP
```
cargo build --release
```
**构建时间**: 5-10 分钟(首次构建会编译所有依赖项)
### 步骤 5: 测试服务器
独立运行 MCP 服务器以验证其是否工作:
```
.\target\release\nexuscore_mcp.exe
```
您应该看到:
```
[INFO] Starting NexusCore MCP Server (RMCP Standard)...
[INFO] Listening on Stdio...
```
**按 `Ctrl+C` 停止**。服务器现在已准备好与 AI 客户端集成。
## 🤖 AI 集成指南 (Claude Desktop / Cursor)
### 适用于 Claude Desktop
1. **找到您的 Claude Desktop 配置文件**:
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Linux**: `~/.config/Claude/claude_desktop_config.json`
2. **编辑配置文件** 并添加 NexusCore MCP:
```
{
"mcpServers": {
"nexuscore": {
"command": "C:\\Path\\To\\NexusCore_MCP\\target\\release\\nexuscore_mcp.exe",
"args": [],
"env": {
"CAPE_API_URL": "http://127.0.0.1:8000",
"RUST_LOG": "info"
}
}
}
}
```
1. **完全重启 Claude Desktop**(退出并重新打开)
2. **验证安装**: 开始新对话并输入:
Can you list all available NexusCore tools?
Claude 应该回复一个恶意软件分析工具列表。
### 适用于 Cursor IDE
1. 打开 **Cursor Settings** → **MCP Servers**
2. 点击 **Add Server** 并输入:
- **Name**: `NexusCore`
- **Command**: `C:\Path\To\NexusCore_MCP\target\release\nexuscore_mcp.exe`
- **Environment Variables**:
- `CAPE_API_URL`: `http://127.0.0.1:8000`
- `RUST_LOG`: `info`
3. **保存** 并重启 Cursor
### 适用于其他 MCP 客户端
使用 stdio 传输将服务器配置添加到客户端的 MCP 设置中:
- **Command**: `nexuscore_mcp.exe` 的路径
- **Transport**: Stdio (stdin/stdout)
- **Protocol**: MCP (Model Context Protocol)
## 💬 使用示例
以下展示了如何通过 AI Agent 与 NexusCore 交互的真实对话示例:
### 示例 1: 快速恶意软件分类
```
You: I have a suspicious file "invoice.exe". Can you analyze it?
Claude: I'll help you analyze invoice.exe. Let me start with static analysis.
[Claude calls die_scan tool]
Claude: The file is detected as:
- Compiler: Microsoft Visual C++ 8.0
- Packer: **UPX 3.96**
- Entropy: High (7.2/8.0) - Likely packed
Let me check for malware capabilities:
[Claude calls capa_tool]
Claude: CAPA detected the following capabilities:
- ✅ Network communication (HTTP)
- [X] Custom Dashboard UI
- [X] Integration with code analysis (Copilot / DeepSeek)
- [ ] Automated Deobfuscation
- [ ] Sandboxed macOS execution
## 创建自定义工具
You can easily extend NexusCore MCP by creating and registering your own custom tools using the `Tool` trait and `inventory` crate. No need to touch the central server registry!
### 1. 实现 `Tool` trait
Create a new file for your tool, e.g., `src/tools/custom/my_tool.rs`:
```rust
use crate::tools::Tool;
use async_trait::async_trait;
use serde_json::Value;
use anyhow::Result;
pub struct MyCustomTool;
#[async_trait]
impl Tool for MyCustomTool {
fn name(&self) -> &str {
"my_custom_tool"
}
fn description(&self) -> &str {
"A custom tool that does something awesome."
}
// You can optionally override `schema` to define JSON Schema parameters
async fn execute(&self, args: Value) -> Result {
// Your logic here
Ok(serde_json::json!({
"status": "success",
"message": "Hello from custom tool!"
}))
}
}
// Automatically register the tool
inventory::submit! {
crate::tools::ToolRegistration::new(|| std::sync::Arc::new(MyCustomTool))
}
```
### 2. 包含模块
确保您的工具模块包含在项目树中。例如,在 `src/tools/custom/mod.rs` 中添加 `pub mod my_tool;`。`inventory::submit!` 宏将在启动时自动将您的工具动态注册到系统中!
## 许可证
本项目采用 MIT 许可证授权。
Recommendation: This is likely malware. Proceed with dynamic analysis in a VM?
```
### 示例 2:绕过反调试保护
```
You: The malware crashes when I debug it. Can you help?
Claude: This suggests anti-debugging protection. I'll spawn it in stealth mode.
[Claude calls spawn_process with stealth=true]
Claude: Process spawned (PID: 4568) with Frida stealth hooks:
- IsDebuggerPresent() → FALSE
- NtQueryInformationProcess() → Patched
- CheckRemoteDebuggerPresent() → Bypassed
The process is now suspended. Let me scan for persistence:
[Claude calls scan_persistence]
Claude: Found persistence mechanism:
- Location: HKCU\Software\Microsoft\Windows\CurrentVersion\Run
- Key: "WindowsUpdate"
- Value: C:\Users\Admin\AppData\Roaming\svchost.exe
Should I resume the process and monitor its behavior?
```
### 示例 3:脱壳与转储
```
You: Can you unpack this Themida-protected binary?
Claude: I'll attempt to find the Original Entry Point (OEP).
[Claude calls spawn_process, then find_oep]
Claude: OEP Analysis:
- Current EIP: 0x004015A0 (Themida stub)
- Detected unpacking loop at 0x00401200
- OEP candidate: 0x00405000 (after 2,450 instructions)
Let me attach and dump the process memory:
[Claude calls attach_process, then memory dump]
Claude: Memory dumped (520 KB). Now fixing the Import Address Table:
[Claude calls iat_fixer]
Claude: IAT reconstructed with 89 imports. The unpacked binary is ready:
📁 Output: invoice_unpacked.exe
Would you like me to analyze the unpacked code with CAPA?
```
### 示例 4:网络行为分析
```
You: What network connections does this malware make?
Claude: Let me spawn the process and monitor its behavior.
[Claude calls spawn_process, scan_handles]
Claude: Detected network activity:
- TCP connection to 192.168.45.23:8080
- HTTP User-Agent: "Mozilla/5.0"
- Mutex: Global\{5F2A8C9D-1234}
Let me check if this IP is known malicious...
[Continues analysis]
```
---
## 📚 分析场景:“破解 Themida”
1. **Initial Triage**:
* Agent calls `die_scan` -> Result: "Themida / WinLicense 2.x".
* Agent calls `cape_submit` -> Result: "Timeout / Crashed" (Sandbox evasion detected).
2. **Stealth Execution**:
* Agent calls `spawn_process(path="malware.exe", stealth=true)`.
* NexusCore spawns process bundled with `stealth_unpacker.js` to hook `IsDebuggerPresent` and `NtQueryInformationProcess`.
3. **Behavior Monitoring**:
* Agent calls `scan_handles` to find Mutex `Global\GoGoMalware`.
* Agent calls `scan_persistence` and finds `HKCU\..\Run\Updater`.
4. **dumping & Fixing**:
* Agent identifies unpacked code region.
* Agent calls `iat_fixer` to rebuild the binary.
---
## 🔧 工具参考
Complete reference for all available tools with parameters and response formats.
### 进程管理工具
#### `spawn_process`
Spawns a process in suspended state with optional Frida instrumentation.
**Parameters:**
```json
{
"path": "C:\\malware\\sample.exe",
"stealth": true, // Optional: Enable anti-debug bypass
"args": ["--config", "test"] // Optional: Command-line arguments
}
```
**响应:**
```
{
"pid": 4568,
"status": "suspended",
"stealth_enabled": true
}
```
#### `attach_process`
附加到现有的正在运行的进程。
**参数:**
```
{
"pid": 4568
}
```
#### `resume_process`
恢复挂起的进程。
**参数:**
```
{
"pid": 4568
}
```
#### `inject_frida_script`
将自定义 Frida JavaScript 注入进程。
**参数:**
```
{
"pid": 4568,
"script": "console.log('Hooked!'); Interceptor.attach(...);"
}
```
### 静态分析工具
#### `die_scan`
使用 Detect It Easy 检测加壳器、编译器和保护器。
**参数:**
```
{
"file_path": "C:\\malware\\sample.exe"
}
```
**响应:**
```
{
"detections": ["UPX 3.96", "MSVS 2019"],
"entropy": 7.2,
"file_type": "PE32"
}
```
#### `capa_tool`
使用 CAPA 分析恶意软件能力。
**参数:**
```
{
"file_path": "C:\\malware\\sample.exe"
}
```
**响应:**
```
{
"capabilities": [
"create TCP socket",
"enumerate files",
"create registry key"
]
}
```
#### `floss_tool`
使用 FLOSS 提取混淆字符串。
**参数:**
```
{
"file_path": "C:\\malware\\sample.exe"
}
```
### 动态分析工具
#### `find_oep`
查找加壳可执行文件的原始入口点。
**参数:**
```
{
"pid": 4568,
"max_instructions": 10000
}
```
**响应:**
```
{
"oep_address": "0x00405000",
"instructions_traced": 2450
}
```
#### `code_disassembler`
反汇编特定地址的代码。
**参数:**
```
{
"pid": 4568,
"address": "0x00401000",
"length": 100
}
```
#### `pe_fixer`
修复转储可执行文件的 PE 头和节。
**参数:**
```
{
"input_file": "C:\\dumps\\memory.bin",
"output_file": "C:\\dumps\\fixed.exe"
}
```
#### `iat_fixer`
使用 Scylla 重建导入地址表。
**参数:**
```
{
"pid": 4568,
"dump_file": "C:\\dumps\\memory.bin"
}
```
### 系统取证工具
#### `scan_persistence`
扫描持久化机制。
**参数:**
```
{
"scan_registry": true,
"scan_startup": true
}
```
响应:**
```
{
"registry_keys": [
{
"hive": "HKCU",
"path": "Software\\Microsoft\\Windows\\CurrentVersion\\Run",
"name": "Updater",
"value": "C:\\malware.exe"
}
],
"startup_files": []
}
```
#### `scan_handles`
列出进程的打开句柄和互斥体。
**参数:**
```
{
"pid": 4568
}
```
**响应:**
```
{
"handles": [
{
"type": "File",
"name": "C:\\Windows\\System32\\notepad.exe"
},
{
"type": "Mutant",
"name": "Global\\MyMalwareMutex"
}
]
}
```
### 沙箱工具
#### `cape_submit`
将样本提交到 CAPEv2 沙箱。
**参数:**
```
{
"file_path": "C:\\malware\\sample.exe",
"timeout": 300
}
```
**响应:**
```
{
"task_id": 12345,
"status": "completed",
"score": 8.5,
"signatures": ["ransomware", "persistence"]
}
```
## 🛠️ 故障排除
### 常见问题与解决方案
#### ❌ Claude Desktop 中出现 "nexuscore_mcp.exe not found"
**解决方案:**
- 确保您已构建项目:`cargo build --release`
- 在配置中使用 **完整的绝对路径**:`C:\\Users\\YourName\\NexusCore_MCP\\target\\release\\nexuscore_mcp.exe`
- 在 Windows 路径中使用双反斜杠 (`\\`)
#### ❌ "Failed to spawn process" 错误
**解决方案:**
- 以 **管理员身份** 运行 Claude Desktop/Cursor
- 确保目标可执行文件存在并具有读取权限
- 检查杀毒软件是否阻止了执行
- 验证 Frida 是否已安装:`pip install frida-tools`
#### ❌ "DIE/CAPA not found" 错误
**解决方案:**
- 重新运行安装脚本:`.\scripts\setup_tools.ps1`
- 手动将工具添加到 PATH:
$env:Path += ";C:\NexusCore_MCP\bin\DetectItEasy"
$env:Path += ";C:\NexusCore_MCP\bin\Capa"
- 重启终端
#### ❌ 构建期间出现 "Rust linker error"
**解决方案:**
- 安装 Visual C++ Build Tools:
choco install visualcpp-build-tools -y
- 或从此处下载:
#### ❌ CAPEv2 连接超时
**解决方案:**
- 验证 CAPE 是否正在运行:在浏览器中打开 `http://127.0.0.1:8000`
- 检查 `.env` 文件中的 `CAPE_API_URL` 是否正确
- CAPE 提交是可选的 - 其他工具可独立工作
#### ❌ 扫描进程时出现 "Access denied"
**解决方案:**
- 以 **管理员身份** 运行您的 MCP 客户端
- 某些系统进程受保护 - 使用虚拟机进行恶意软件分析
### 调试模式
通过在 `.env` 中设置以下内容来启用详细日志记录:
```
RUST_LOG=debug
```
实时查看日志:
```
.\target\release\nexuscore_mcp.exe 2> debug.log
```
### 获取帮助
- **问题反馈**: [GitHub Issues](https://github.com/yourusername/NexusCore_MCP/issues)
- **文档**: 检查 `/docs` 文件夹(如果可用)
- **社区**: 在仓库中加入讨论
## ⚠️ 免责声明
此工具仅用于 **授权的安全研究和恶意软件分析**。作者和贡献者不对因使用本软件而造成的任何误用或损害负责。**务必在隔离的虚拟机中运行恶意软件。**
## 📄 许可证
MIT 许可证
标签:AI驱动安全, Claude集成, DNS信息、DNS暴力破解, Frida动态插桩, Ghidra集成, GPT-4集成, IDA插件, LLM安全工具, MCP服务器, Rust编程, SecList, Unicorn Engine, YARA规则, 云资产清单, 内存取证, 动态恶意软件分析, 可视化界面, 恶意软件调试, 模型上下文协议, 沙箱逃逸检测, 用户代理, 端点可见性, 网络安全, 脱壳, 自动化分析, 跨站脚本, 进程注入检测, 逆向工具, 逆向工程, 通知系统, 隐私保护