████████╗██╗ ██╗██████╗ ███████╗ █████╗ ████████╗ ███████╗ ██████╗ ███╗ ██╗███████╗███╗ ███╗ ██████╗██████╗
╚══██╔══╝██║ ██║██╔══██╗██╔════╝██╔══██╗╚══██╔══╝ ╚══███╔╝██╔═══██╗████╗ ██║██╔════╝████╗ ████║██╔════╝██╔══██╗
██║ ███████║██████╔╝█████╗ ███████║ ██║ ███╔╝ ██║ ██║██╔██╗ ██║█████╗ ██╔████╔██║██║ ██████╔╝
██║ ██╔══██║██╔══██╗██╔══╝ ██╔══██║ ██║ ███╔╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╔╝██║██║ ██╔═══╝
██║ ██║ ██║██║ ██║███████╗██║ ██║ ██║ ██╗███████╗╚██████╔╝██║ ╚████║███████╗██║ ╚═╝ ██║╚██████╗██║
╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝ ╚═════╝╚═╝ 威胁。区域MCP服务器
用于威胁的模型上下文协议(MCP)服务器。API区,采用FastMCP构建。此服务器为LLM提供对Threat的访问权限。通过标准化的MCP工具实现Zone的恶意软件分析功能。
特性
- 文件分析:提交用于恶意软件分析的文件,包括沙盒执行、静态分析和CDR(内容解除武装和重建)
- URL分析:分析URL中的威胁和恶意内容
- 提交管理:检索详细的分析结果、指标、IoC和YARA规则
- 网络分析:访问DNS查询、HTTP/TCP/UDP请求和网络威胁
- 报告生成:下载经过净化的文件和HTML报告
- 用户管理:获取用户信息和提交限制
安装
使用pip
pip install threatzone-mcp使用紫外线(推荐)
uv add threatzone-mcp开发安装
git clone https://github.com/threat-zone/threatzonemcp.git
cd threatzonemcp
uv sync --dev配置
设置你的威胁。区域API凭据作为环境变量:
export THREATZONE_API_KEY="your_api_key_here"
# Optional: For private tenants or on-premise deployments
export THREATZONE_API_URL="https://your-tenant.threat.zone"或者创建一个 .env 文件:
THREATZONE_API_KEY=your_api_key_here
# Optional: Custom API URL (defaults to https://app.threat.zone)
THREATZONE_API_URL=https://your-tenant.threat.zone支持的部署
- 公共云:
https://app.threat.zone(默认) - 私人租户:
https://your-tenant.threat.zone - 前提的:
https://your-server.company.com
连接威胁。将MCP服务器区域连接到Claude桌面
先决条件
- 已安装Claude Desktop -下载自 克劳德桌面版
- UV已安装 -
brew install uv或curl -LsSf https://astral.sh/uv/install.sh | sh - 威胁。API区域密钥 -从 威胁。分区设置
设置步骤
1.准备MCP服务器
# Clone and setup the project
git clone
cd threatzonemcp
# Install with UV
uv venv
uv pip install -e .
# Test the server works
THREATZONE_API_KEY=your_key uv run threatzone-mcp
# Should start without errors2.配置克劳德桌面
选项A:使用紫外线(推荐)
- 查找您的Claude Desktop配置目录:
- macOS: ~/Library/Application Support/Claude/ - 视窗: %APPDATA%\Claude\ - Linux: ~/.config/Claude/
- 创建或编辑
claude_desktop_config.json:
{
"mcpServers": {
"threatzone": {
"command": "uv",
"args": [
"run",
"--directory",
"/full/path/to/your/threatzonemcp",
"threatzone-mcp"
],
"env": {
"THREATZONE_API_KEY": "your_actual_api_key_here",
"THREATZONE_API_URL": "https://your-tenant.threat.zone"
}
}
}
}选项B:直接使用Python
{
"mcpServers": {
"threatzone": {
"command": "python",
"args": [
"-m",
"threatzone_mcp.server"
],
"cwd": "/full/path/to/your/threatzonemcp",
"env": {
"THREATZONE_API_KEY": "your_actual_api_key_here",
"PYTHONPATH": "/full/path/to/your/threatzonemcp/src"
}
}
}
}选项C:直接使用虚拟环境
{
"mcpServers": {
"threatzone": {
"command": "/full/path/to/your/threatzonemcp/.venv/bin/python",
"args": [
"-m",
"threatzone_mcp.server"
],
"cwd": "/full/path/to/your/threatzonemcp",
"env": {
"THREATZONE_API_KEY": "your_actual_api_key_here",
"PYTHONPATH": "/full/path/to/your/threatzonemcp/src"
}
}
}
}3.重要配置说明
- 替换占位符:
- 替换 /full/path/to/your/threatzonemcp 实际完整路径 - 替换 your_actual_api_key_here 你的威胁。API区密钥
- 获取完整路径:
cd threatzonemcp
pwd # This shows the full path- 验证API密钥:通过测试确保API密钥有效:
# For public cloud (default)
curl -H "Authorization: Bearer your_api_key" https://app.threat.zone/public-api/me
# For private tenant or on-premise
curl -H "Authorization: Bearer your_api_key" https://your-tenant.threat.zone/public-api/me- API URL配置 (可选):
- 公共云:无需设置 THREATZONE_API_URL (使用默认值) - 私人租户:设置 THREATZONE_API_URL=https://your-tenant.threat.zone - 前提的:设置 THREATZONE_API_URL=https://your-server.company.com
4.重新启动克劳德桌面
保存配置后:
- 完全退出克劳德桌面
- 重新启动克劳德桌面
- 寻找🔌 图标 在新的聊天中确认MCP服务器已连接
5.测试连接
在Claude Desktop中,尝试询问:
“你能得到我的Threat.Zone用户信息吗?”
或
“threat.Zone中的可用威胁级别是什么?”
Claude应该能够使用MCP工具与威胁进行交互。API区。
故障排除
常见问题
- “找不到服务器”错误:
- 检查完整路径是否正确 - 验证UV是否已安装并位于PATH中 - 手动测试命令: uv run --directory /path/to/threatzonemcp threatzone-mcp
- “需要API密钥”错误:
- 验证在env部分中是否正确设置了API密钥 - 使用curl测试API密钥的工作情况
- “权限被拒绝”错误:
- 确保脚本可执行 - 检查文件权限
- Python导入错误:
- 验证虚拟环境是否已正确设置 - 检查Python是否包含src目录
可用工具
一旦连接,克劳德将可以访问这些威胁。区域工具:
分析工具
- URL分析:
scan_url-分析URL中的威胁 - 文件分析:
- scan_file_sandbox -具有完整配置的高级沙盒分析 - scan_file_sandbox_simple -带有默认值的简单沙盒分析 - scan_file_static -静态文件分析 - scan_file_cdr -内容解除武装与重建
结果与监测
- 提交详情:
get_submission,get_submission_status_summary - 威胁情报:
get_submission_indicators,get_submission_iocs - 检测规则:
get_submission_yara_rules,get_submission_varist_results - 网络活动:
get_submission_dns,get_submission_http,get_submission_tcp,get_submission_udp,get_submission_network_threats - 人工制品:
get_submission_artifacts,get_submission_config_extractor
辅助函数
- 状态解释:
interpret_status,interpret_threat_level - 常量:
get_metafields,get_levels,get_statuses,get_sample_metafield
用户管理
- 账户信息:
get_user_info - 提交历史记录:
get_my_submissions,get_public_submissions - 搜索:
search_by_hash
下载
- 文件:
download_sanitized_file(CDR已清理文件) - 报告:
download_html_report(详细分析报告)
克劳德对话示例
连接后,您可以问Claude以下问题:
“在启用Windows 11环境和互联网访问的情况下分析此可疑的PDF文件”
“检查我最近提交的状态,并向我显示任何发现的恶意软件”
“提交UUID abc-123的网络连接和DNS查询是什么?”
“下载我最新提交的分析报告”
“监控提交进度,并在分析完成时通知我”
Claude将使用适当的MCP工具与Threat进行交互。分区并提供全面的恶意软件分析见解!
用法
运行服务器
# Using the installed script
threatzone-mcp
# Or directly with Python
python -m threatzone_mcp.server可用工具
服务器提供以下MCP工具:
常量和助手
get_metafields()-获取可用图元字段以进行高级配置get_levels()-获取威胁级别get_statuses()-获取提交状态get_sample_metafield()-获取沙盒分析的示例配置interpret_status(status_value)-将数字状态转换为人类可读的描述interpret_threat_level(level_value)-将数字威胁级别转换为描述get_submission_status_summary(uuid)-获取带有解释状态和威胁级别的提交get_server_config()-获取当前服务器配置和连接状态
用户信息
get_user_info()-获取当前用户信息和限制
扫描
scan_url(url, is_public=False)-分析URLscan_file_sandbox(file_path, ...)-提交具有完整配置的高级沙盒分析文件scan_file_sandbox_simple(file_path, is_public=False, entrypoint=None, password=None)-使用默认设置提交沙盒分析文件scan_file_static(file_path, is_public=False, entrypoint=None, password=None)-提交静态分析文件scan_file_cdr(file_path, is_public=False, entrypoint=None, password=None)-提交文件以进行CDR处理
提交检索
get_submission(uuid)-获取提交详细信息get_submission_indicators(uuid)-获取提交指标get_submission_iocs(uuid)-获取妥协指标get_submission_yara_rules(uuid)-获取匹配的YARA规则get_submission_varist_results(uuid)-获取Varist混合分析仪结果get_submission_artifacts(uuid)-获取分析工件get_submission_config_extractor(uuid)-获取提取的配置
网络分析
get_submission_dns(uuid)-获取DNS查询get_submission_http(uuid)-获取HTTP请求get_submission_tcp(uuid)-获取TCP请求get_submission_udp(uuid)-获取UDP请求get_submission_network_threats(uuid)-获取网络威胁
用户提交
get_my_submissions(page=1, jump=10)-获取用户提交的内容get_public_submissions(page=1, jump=10)-获取公开提交search_by_hash(hash, page=1, jump=10)-按哈希值搜索提交内容
下载
download_sanitized_file(uuid)-下载CDR净化文件download_html_report(uuid)-下载HTML分析报告
高级沙盒分析
这 scan_file_sandbox 该工具支持全面的配置选项,用于详细的恶意软件分析:
环境选项
- 视窗:
w7_x64,w10_x64,w11_x64 - macOS:
macos - 安卓:
android - Linux:
linux
分析配置
- 超时:60、120、180、240或300秒
- 工作路径:
desktop,root,%AppData%,windows,temp - 鼠标模拟:启用/禁用用户交互模拟
- Internet连接:允许/阻止网络访问
- HTTPS检查:监视加密流量
- 原始日志:包括详细的执行日志
- 快照:在执行过程中捕获VM状态
- 睡眠逃避:检测反分析技术
- 智能追踪:高级行为分析
- 垃圾收集器:收集内存转储
使用示例
简单分析:
# Use default settings
await client.call_tool("scan_file_sandbox_simple", {
"file_path": "/path/to/file.exe"
})高级分析:
# Full configuration control
await client.call_tool("scan_file_sandbox", {
"file_path": "/path/to/file.exe",
"environment": "w11_x64",
"timeout": 300,
"internet_connection": True,
"https_inspection": True,
"raw_logs": True,
"modules": ["csi", "cdr"]
})看 examples/advanced_sandbox_example.py 查看详细的使用示例。
了解结果
提交状态值
API返回数字状态代码,指示您提交的当前状态:
| 值 | 状态 | 描述 |
|---|---|---|
| 1 | 文件已收到 | 文件已上传并排队等待分析 |
| 2 | 提交失败 | 由于错误或超时,分析失败 |
| 3 | 提交正在运行 | 分析当前正在进行中 |
| 4 | 提交VM就绪 | 虚拟机已准备就绪并开始分析 |
| 5 | 提交完成 | 分析成功完成 |
威胁级别值
分析结果包括指示发现严重程度的威胁级别:
| 值 | 级别 | 描述 |
|---|---|---|
| 0 | 未知 | 无法确定威胁级别 |
| 1 | 信息性 | 文件看起来是良性的,有一些明显的行为 |
| 2 | 可疑 | 文件具有潜在的恶意特征 |
| 3 | 恶意 | 文件被确认为恶意软件或高度危险 |
使用示例
检查提交状态:
# Get raw status
submission = await client.call_tool("get_submission", {"uuid": "submission_id"})
print(f"Status code: {submission['status']}")
# Get interpreted status
summary = await client.call_tool("get_submission_status_summary", {"uuid": "submission_id"})
print(f"Status: {summary['status_description']}")
print(f"Threat Level: {summary['threat_level_description']}")监控分析进度:
import asyncio
async def wait_for_analysis(uuid):
while True:
summary = await client.call_tool("get_submission_status_summary", {"uuid": uuid})
status = summary.get('status')
if status == 5: # Finished
print(f"Analysis complete! Threat level: {summary['threat_level_description']}")
break
elif status == 2: # Failed
print("Analysis failed")
break
else:
print(f"Status: {summary['status_description']}")
await asyncio.sleep(10) # Wait 10 seconds before checking againapi参考
所有工具都遵循威胁。API区规范。有关详细的参数说明和响应格式,请参阅 威胁。API区域文件.
错误处理
该服务器包括全面的错误处理功能,用于:
- 身份验证失败(401)
- 无效请求(400/422)
- 未发现错误(404)
- 速率限制
- 网络问题
许可证
GPL v3许可证。看 许可证 了解详情。
贡献
- 复刻仓库
- 创建要素分支
- 进行更改
- 添加测试
- 提交拉取请求
支持
对于问题和疑问:
- 威胁。区域文件
- 电子邮件:info@malwation.com
