APT分析MCP服务器
一种MCP(模型上下文协议)服务器,旨在协助APT(高级持久性威胁)恶意软件分析。目前提供通过跳转服务器安全下载样本的工具。
特性
- 样本下载器:使用SSH/SCP通过跳转主机从远程服务器安全下载恶意软件样本。
- 规则哈希查询:按规则名称和命名空间查询与YARA规则关联的示例哈希。
- 集成工作流:直接按YARA规则名称下载示例。
安装
- 克隆存储库:
git clone https://github.com/zrax-x/apt-analysis-mcp.git
cd apt-analysis-mcp- 安装依赖项:
建议使用虚拟环境。
python -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # Linux/Mac
pip install -r requirements.txt配置
- 复制示例配置:
copy config.example.json config.json- 编辑
config.json:
填写跳线和目标服务器的SSH详细信息,指定本地下载目录,并配置规则哈希映射文件路径。
{
"jumper": {
"user": "your_jumper_user",
"host": "jump_server_ip",
"port": 22,
"key": "~/.ssh/id_rsa_jumper"
},
"target": {
"user": "your_target_user",
"host": "target_server_ip",
"port": 22,
"workdir": "/path/to/target/workdir",
"key": "~/.ssh/id_rsa_target"
},
"local_download_dir": "/path/to/local/samples",
"rule_hash_mapping_file": "/path/to/Rule_Hash_Mapping.csv"
}配置字段:
- jumper:跳转服务器(堡垒主机)SSH配置 - target:存储样本的目标服务器SSH配置 - local_download_dir:保存下载样本的本地目录 - rule_hash_mapping_file:Rule_Hash_Mapping.csv文件的路径(建议使用绝对路径)
- 生成规则哈希映射:
服务器需要 Rule_Hash_Mapping.csv 文件。通过运行以下命令生成:
cd /path/to/yara_rules_parent_directory
python3 build_rule_hash_mapping.py这将扫描所有YARA规则并创建映射表。然后更新 rule_hash_mapping_file 路径在 config.json 指向此文件。
使用Claude Desktop
将服务器添加到您的 claude_desktop_config.json (通常在 %APPDATA%\Claude\ 在Windows上)。
{
"mcpServers": {
"apt-analysis": {
"command": "path/to/your/venv/Scripts/python.exe",
"args": [
"path/to/apt-analysis-mcp/server.py"
]
}
}
}可用工具
1.下载_示例
通过SHA256哈希下载恶意软件样本。
参数:
hash_list(list\[str\]):要下载的SHA256哈希列表output_dir(str,可选):保存样本的本地目录(默认为local_download_dir在配置中)
例子:
Download samples with hashes: ["3123bbd5564f4381820fb8da5810bd4d9718b5c80a7e8f055961007c6f30daff", "..."]退货:
"Successfully downloaded samples to /path/to/samples"______________________________________________________________________
2.get_rule_sha256_list
获取YARA规则的SHA256哈希列表(准备下载示例)。
此工具查询Rule_Hash_Mapping.csv文件(在中配置 config.json)以检索与特定YARA规则相关联的SHA256哈希。返回的哈希值可以直接与 download_samples 工具。
参数:
rule(str,必填):YARA规则名称(例如“APT_xxx”)namespace(str,可选):精确匹配的YARA文件路径(例如,“./YARA_rules/xxx/pe_rules/abc.YARA”)
- 如果未提供,则返回与规则名称匹配的所有规则 - 如果提供,则仅返回完全匹配的结果
示例用法:
Get SHA256 list for rule: APT_xxx退货:
{
"success": true,
"sha256_hashes": [
"3123bbd5564f4381820fb8da5810bd4d9718b5c80a7e8f055961007c6f30daff",
"123408972b8ec9c2e64eeb46ce1db92ae3c40bc8de48d278ba4d436fc3c8b3a4",
"ffaab4463be9d8131f363fd78e21d9de5d838a3ec4044526aea45a473d6ddd61",
"..."
],
"count": 9,
"error": null
}错误响应:
{
"success": false,
"sha256_hashes": [],
"count": 0,
"error": "No SHA256 hashes found for rule: nonexistent_rule"
}笔记:
- 该工具从
rule_hash_mapping_file配置在config.json - 仅返回SHA256哈希值(不包括MD5哈希值,因为下载需要SHA256)
- 如果规则出现在多个文件中,则自动对哈希值进行重复数据消除
- 如果找不到或未配置映射文件,则返回错误
工作流示例
示例1:查询和下载示例
Step 1: Get SHA256 list for rule: APT_IN_xxx
Step 2: Download samples with the returned SHA256 hashes示例2:下载特定规则示例
1. Get SHA256 list for rule: M_Hunting_yyy
2. Copy the SHA256 hashes from the response
3. Download samples with those hashes to /home/user/samples发展
- 添加新工具:在中创建新模块
tools/并将其注册到server.py.
