巨盗龙MCP
一种模型上下文协议(MCP)服务器,为AI助手提供访问 迅猛龙 -强大的数字取证和事件响应(DFIR)平台。
概述
Megaraptor MCP使像Claude这样的人工智能助手能够与Velociraptor服务器进行交互,以:
- 端点管理:搜索、审问和管理Velociraptor客户
- 文物收藏:安排端点上的取证工件收集
- 威胁狩猎:创建和管理跨多个端点的狩猎
- VQL查询:执行任意Velociraptor查询语言查询
- 事件响应:针对常见场景的预构建DFIR工作流提示
- 部署自动化:跨基础设施(Docker、二进制、云、GPO、SSH、WinRM、Ansible)部署Velociraptor服务器和代理
特性
MCP工具(33个工具)
核心DFIR工具(15个工具)
| 类别 | 工具 | 描述 |
|---|---|---|
| 客户 | list_clients | 搜索并列出迅猛龙端点 |
get_client_info | 获取客户的详细信息 | |
label_client | 在客户端添加/删除标签 | |
quarantine_client | 隔离或释放端点 | |
| 人工制品 | list_artifacts | 列出可用的迅猛龙文物 |
get_artifact | 获取完整的工件定义 | |
collect_artifact | 在客户端上安排工件收集 | |
| 狩猎 | create_hunt | 发起一场大规模的募捐活动 |
list_hunts | 列出现有狩猎 | |
get_hunt_results | 检索搜索结果 | |
modify_hunt | 开始、暂停、停止或存档狩猎 | |
| 流动 | list_flows | 列出客户端的收集流 |
get_flow_results | 从集合中获取结果 | |
get_flow_status | 检查收款状态 | |
cancel_flow | 取消正在运行的收藏 | |
| VQL | run_vql | 执行任意VQL查询 |
vql_help | 获取有关VQL语法和插件的帮助 |
部署工具(18个工具)
| 类别 | 工具 | 描述 |
|---|---|---|
| 服务器部署 | deploy_server_binary | 将Velociraptor服务器部署为独立二进制文件 |
deploy_server_docker | 使用Docker部署Velociraptor服务器 | |
deploy_server_cloud | 将Velociraptor服务器部署到AWS/Azure云 | |
generate_server_config | 使用证书生成服务器配置 | |
| 代理部署 | deploy_agent_gpo | 为Windows生成GPO部署包 |
deploy_agent_winrm | 通过WinRM将代理部署到Windows端点 | |
deploy_agent_ssh | 通过SSH将代理部署到Linux/macOS端点 | |
deploy_agent_ansible | 为代理部署生成Ansible剧本 | |
build_offline_collector | 构建独立的离线收集器 | |
generate_client_config | 生成客户端配置文件 | |
| 部署管理 | list_deployments | 列出跟踪的部署操作 |
get_deployment_status | 获取部署的详细状态 | |
verify_deployment | 验证部署运行状况和连接性 | |
rollback_deployment | 回滚失败的部署 | |
| 凭证 | store_credential | 安全地存储部署凭据 |
list_credentials | 列出存储的凭据别名 | |
delete_credential | 删除存储的凭据 | |
| 公用事业 | download_velociraptor | 下载Velociraptor平台二进制文件 |
MCP资源
通过标准化的URI浏览Velociraptor数据:
velociraptor://clients-浏览连接的端点velociraptor://clients/{client_id}-查看特定客户详细信息velociraptor://hunts-浏览狩猎活动velociraptor://hunts/{hunt_id}-查看特定狩猎详情velociraptor://artifacts-浏览可用工件velociraptor://server-info-查看服务器信息velociraptor://deployments-浏览部署操作和状态
MCP提示(8个提示)
预构建的DFIR和部署工作流提示:
| 提示 | 类别 | 描述 |
|---|---|---|
investigate_endpoint | DFIR | 综合终点调查工作流程 |
threat_hunt | DFIR | 创建和执行威胁狩猎活动 |
triage_incident | DFIR | 快速事件分诊和范围界定 |
malware_analysis | DFIR | 分析可疑文件或流程 |
lateral_movement | DFIR | 检测横向移动指示灯 |
deploy_velociraptor | 部署 | 交互式Velociraptor部署向导 |
scale_deployment | 部署 | 规划企业级代理部署 |
troubleshoot_deployment | 部署 | 诊断并修复部署问题 |
安装
先决条件
- Python 3.10或更高版本
- 已启用API访问的正在运行的Velociraptor服务器
- API客户端凭据(请参阅 配置)
从源代码安装
git clone https://github.com/yourusername/megaraptor-mcp.git
cd megaraptor-mcp
# Core DFIR functionality only
pip install -e .
# With deployment features
pip install -e ".[deployment]"
# With cloud deployment (AWS/Azure)
pip install -e ".[cloud]"
# All features
pip install -e ".[all]"可选依赖关系
| 额外 | 功能 | 套餐 |
|---|---|---|
deployment | 代理/服务器部署 | paramiko、pywinrm、密码学、jinja2 |
cloud | 云部署 | boto3、azure mgmt计算 |
all | 所有功能 | 以上所有 |
手动安装依赖项
# Core only
pip install mcp pyvelociraptor pyyaml grpcio
# For deployment features
pip install paramiko pywinrm cryptography jinja2
# For cloud deployment
pip install boto3 azure-mgmt-compute azure-identity配置
Megaraptor MCP支持两种身份验证方法:
选项1:配置文件(推荐)
- 在Velociraptor服务器上生成API客户端配置:
velociraptor --config server.config.yaml config api_client \
--name mcp-client \
--role reader,investigator \
api_client.yaml- 设置环境变量:
export VELOCIRAPTOR_CONFIG_PATH=/path/to/api_client.yaml选项2:环境变量
设置单个配置值:
export VELOCIRAPTOR_API_URL=https://velociraptor.example.com:8001
export VELOCIRAPTOR_CLIENT_CERT=/path/to/client.crt # or PEM content
export VELOCIRAPTOR_CLIENT_KEY=/path/to/client.key # or PEM content
export VELOCIRAPTOR_CA_CERT=/path/to/ca.crt # or PEM contentAPI角色
根据所需的功能为API客户端分配适当的角色:
| 角色 | 能力 |
|---|---|
reader | 读取客户、工件、狩猎、流量 |
investigator | 以上+收集文物,创建狩猎 |
administrator | 完全访问(谨慎使用) |
用法
运行服务器
# Using the installed command
megaraptor-mcp
# Or as a Python module
python -m megaraptor_mcpClaude桌面集成
添加到您的Claude Desktop配置(claude_desktop_config.json):
{
"mcpServers": {
"velociraptor": {
"command": "python",
"args": ["-m", "megaraptor_mcp"],
"env": {
"VELOCIRAPTOR_CONFIG_PATH": "/path/to/api_client.yaml"
}
}
}
}交互示例
列出连接的端点:
Use the list_clients tool to show all Windows endpoints调查端点:
Use the investigate_endpoint prompt for client C.1234567890abcdef创建威胁狩猎:
Create a hunt for the file hash a1b2c3d4e5f6... across all endpoints运行自定义VQL:
Run this VQL query: SELECT * FROM pslist() WHERE Name =~ 'suspicious'VQL参考
VQL(Velociraptor查询语言)是核心查询语言。常见模式:
-- List all clients
SELECT * FROM clients()
-- Search for clients by hostname
SELECT * FROM clients(search='host:workstation')
-- Get running processes from collected data
SELECT * FROM source(client_id='C.xxx', flow_id='F.xxx')
-- Create a hunt
SELECT hunt(artifacts='Windows.System.Pslist', description='Process audit')
FROM scope()有关完整的VQL参考,请参阅:https://docs.velociraptor.app/vql_reference/
部署功能
Megaraptor MCP包括Velociraptor基础设施的全面部署自动化。
服务器部署
使用多种方法部署Velociraptor服务器:
| 方法 | 用例 | 命令 |
|---|---|---|
| 二进制 | 现场直接安装 | deploy_server_binary |
| 码头工人 | 容器环境,快速测试 | deploy_server_docker |
| 云 | AWS/Azure管理部署 | deploy_server_cloud |
示例:部署Docker服务器
Deploy a Velociraptor server using Docker on server.example.com with SSH credentials "prod-server"代理部署
针对不同环境的多种代理部署方法:
| 方法 | 目标 | 最适合 |
|---|---|---|
| GPO | Windows(Active Directory) | 企业Windows环境 |
| 远程管理 | Windows(远程) | 不带AD的Windows,较小的部署 |
| 安全外壳协议 | Linux/macOS | 类Unix系统 |
| 安塞波 | 多平台 | 大规模基础设施自动化 |
| 离线收集器 | 空气间隙 | 孤立的网络,法医收集 |
示例:通过GPO部署代理
Generate a GPO deployment package for 500 Windows endpoints using the enterprise profile示例:通过Ansible部署
Create an Ansible playbook to deploy Velociraptor agents to all Linux servers in inventory.yml部署配置文件
针对不同场景的预配置部署配置文件:
| 简介 | 用例 | 特性 |
|---|---|---|
| 快速 | 快速测试,POC | 最小配置,自签名证书 |
| 标准 | 生产单点 | 合格证书,标准硬化 |
| 企业 | 大规模多站点 | HA配置、高级监控、合规性 |
凭据管理
安全地存储部署凭据:
Store SSH credentials for prod-servers with username admin and key file ~/.ssh/prod_key凭据在静态时使用AES-256-GCM和本地生成的密钥进行加密。
线下收藏家
为气隙环境构建独立收集器:
Build an offline collector for Windows that collects browser history and network connections收集器包括嵌入式配置,可以在没有网络连接的情况下运行。
项目结构
megaraptor-mcp/
├── pyproject.toml # Project configuration
├── README.md # This file
├── src/
│ └── megaraptor_mcp/
│ ├── __init__.py # Package initialization
│ ├── __main__.py # Module entry point
│ ├── server.py # MCP server main entry
│ ├── client.py # Velociraptor API wrapper
│ ├── config.py # Configuration handling
│ ├── tools/ # MCP tool implementations
│ │ ├── clients.py # Client management tools
│ │ ├── artifacts.py # Artifact tools
│ │ ├── hunts.py # Hunt management tools
│ │ ├── flows.py # Flow/collection tools
│ │ └── vql.py # VQL query tools
│ ├── resources/ # MCP resource implementations
│ │ └── resources.py
│ ├── prompts/ # MCP prompt implementations
│ │ └── prompts.py
│ └── deployment/ # Deployment automation
│ ├── __init__.py # Deployment module init
│ ├── tools.py # Deployment tool implementations
│ ├── server/ # Server deployment
│ │ ├── __init__.py
│ │ ├── binary.py # Binary deployment
│ │ ├── docker.py # Docker deployment
│ │ └── cloud.py # Cloud deployment (AWS/Azure)
│ ├── agent/ # Agent deployment
│ │ ├── __init__.py
│ │ ├── gpo.py # GPO package generation
│ │ ├── winrm.py # WinRM deployment
│ │ ├── ssh.py # SSH deployment
│ │ ├── ansible.py # Ansible playbook generation
│ │ └── offline.py # Offline collector builder
│ ├── credentials.py # Secure credential storage
│ ├── config_generator.py # Config file generation
│ └── profiles.py # Deployment profiles (rapid/standard/enterprise)
└── tests/ # Test suite
├── test_config.py
└── test_deployment.py安全考虑
API安全
- API证书:安全存储API客户端凭据。配置文件包含私钥。
- 最小特权原则:为API客户端使用所需的最低角色。
- 网络安全:确保只能从受信任的网络访问API连接。
- 审计日志:Velociraptor记录所有API操作。定期审查日志。
- 检疫注意事项:隔离工具可以将端点与网络隔离。
部署安全
- 凭证加密:部署凭据在静态时使用AES-256-GCM进行加密。这
.keyfile是本地生成的,应该受到保护。 - 生成的配置:服务器和客户端配置包含CA证书和私钥。这些通过以下方式从git中排除
.gitignore. - 可理解的剧本:生成的剧本可能包含CA证书。安全存储并限制访问。
- 云模板:CloudFormation和ARM模板可能包含敏感参数。提交前进行审查。
- SSH/WinRM:尽可能使用基于密钥的身份验证。避免以纯文本形式存储密码。
- 线下收藏家:内置收集器包含嵌入式配置。像代理二进制文件一样进行保护。
- GPO包:MSI包包含嵌入式配置。控制对分发共享的访问。
发展
运行测试
pip install -e ".[dev]"
pytest贡献
- 分叉存储库
- 创建要素分支
- 进行更改
- 运行测试
- 提交拉取请求
许可证
MIT许可证-有关详细信息,请参阅许可证文件。
资源
致谢
- Velocidex的Velociraptor团队创造了一个令人惊叹的DFIR平台
- 模型上下文协议规范的拟人化
