返回市场
MCP-过去时间-服务器

MCP-过去时间-服务器

作者:arch3rPro4 星标更新:2025-11-21

项目介绍

<h1 align="center">MCP-PST-Server</h1> <p align="center"> <em>Windows AI辅助渗透测试MCP服务器</em> </p> <p align="center"> <a href="README-ZH.md"><strong>中文文档 </strong></a> | <a href="README.md"><strong>英文README</strong></a> </p>

PST MCP服务器 是一个轻量级API桥接器,旨在连接MCP客户端(如Cherry Studio、Claude Desktop)到API服务器,从而在Windows终端上执行命令。这使得AI代理或AI客户端能够无缝调用Windows环境中的各种渗透测试工具,实现AI辅助渗透测试

这使AI能够运行终端工具如nmapehole等,并通过curlgobuster等工具与Web应用程序交互,在实时解决CTF Web挑战的同时,协助解决HTB或THM上的机器

目录结构

  • pst_server.py: Windows API服务器(端点:/api/tools/<tool>/api/command/health
  • mcp_server.py: MCP客户端,封装工具为MCP工具并转发至API服务器

🔍 使用场景

目标是通过以下方式启用AI驱动的进攻性安全测试:

  • 让MCP与AI端点(如OpenAI、Claude、DeepSeek或其他模型)进行交互。
  • 暴露API以在Windows机器上执行命令。
  • 使用AI建议并运行终端命令以解决CTF挑战或自动化渗透测试任务。
  • 允许MCP应用发送自定义请求(例如curlnmapehole等),并接收结构化的输出。

🚀 功能

  • 🧠 AI端点集成:将你的Windows机器连接到你喜欢的MCP,如Claude Desktop或Cherry-Studio。
  • 🖥️ 命令执行API:暴露受控API以在你的Windows机器上执行终端命令。
  • 🕸️ Web挑战支持:AI可以与网站和API交互,通过curl和其他AI需要的工具捕获旗帜。
  • 🔐 专为进攻性安全专业人士设计:适合红队成员、漏洞赏金猎人或CTF玩家自动化常见任务。
  • 📊 自动字典管理:自动生成和管理安全测试字典(密码、管理员账户、API端点)。
  • 🗂️ 临时文件管理:自动管理安全测试过程中创建的临时文件。
  • 📈 性能监控:内置性能监控和所有操作的详细日志记录。
  • 🔄 错误处理及重试机制:具有强大错误处理能力的自动重试机制。
  • 🌐 多种传输模式:支持stdio、SSE和HTTP传输模式。
  • 📚 全面文档:详细的用户指南、API参考和集成示例。

🛠️ 安装

在渗透测试Windows机器上(将作为PST服务器)

git clone https://github.com/arch3rPro/MCP-PST-Server.git
cd MCP-PST-Server
pip install -r requirements.txt
python3 pst_server.py

在你的MCP客户端上(可以在Windows或Linux上运行)

  • 你将想要运行 python3 /绝对路径/to/mcp_server.py http://WINDOWS_IP:5100

针对Claude Desktop的配置:

编辑claude_desktop_config.json

{
    "mcpServers": {
        "pst_mcp": {
            "command": "python3",
            "args": [
                "/绝对路径/to/mcp_server.py",
                "--server",
                "http://WINDOWS_IP:5100/"
            ]
        }
    }
}

针对Cherry Studio的配置:

{
    "mcpServers": {
        "PST-MCP": {
            "name": "pst_mcp",
            "type": "stdio",
            "isActive": true,
            "command": "python3",
            "args": [
                "/绝对路径/to/mcp_server.py",
                "--server",
                "http://localhost:5100"
            ]
        }
    }
}

安装常见的渗透测试工具(使用Scoop和PST-Bucket)

  1. 安装Scoop: https://scoop.sh/
  2. 添加PST-Bucket:
    • scoop bucket add ar https://github.com/arch3rPro/PST-Bucket
  3. 安装工具(示例,根据需要调整):
    • scoop install nmap httpx ffuf feroxbuster fscan hydra hackbrowserdata
    • scoop install subfinder dnsx naabu nuclei katana bbot
    • scoop install masscan nikto gobuster john ehole
    • scoop install metasploit(如果不可用,请参阅官方安装程序)
    • 可选:pip install sqlmap
    • Netcat:使用ncat(随nmap一起安装),或nc(可选)

建议:使用Pentest-Windows环境镜像(带有许多工具):https://github.com/arch3rPro/Pentest-Windows

启动API服务器

PST API服务器支持各种命令行选项用于配置:

命令行选项

python pst_server.py [选项]
  • --host 主机地址:服务器主机地址(默认:0.0.0.0)
  • --port 端口号:服务器端口号(默认:5100)
  • --timeout 秒数:命令执行超时时间(秒)(默认:180)
  • --debug:启用调试模式以进行详细日志记录

使用自定义选项启动API服务器

  • 导航到目录:/绝对路径/to/MCP-PST-Server
  • 使用默认设置启动:
    • python pst_server.py
  • 使用自定义设置启动:
    • python pst_server.py --host 0.0.0.0 --port 15100 --timeout 300 --debug
  • 健康检查(PowerShell):
    • Invoke-RestMethod -Uri http://localhost:5100/health -Method GET

使用自定义选项启动MCP服务器

MCP服务器支持多种传输模式,并可通过各种参数进行配置:

传输模式

  1. STDIO模式(默认):标准输入/输出通信,适用于大多数MCP客户端,如Claude Desktop
  2. SSE模式:服务器发送事件传输,适用于基于Web的客户端
  3. HTTP模式:直接HTTP API访问,适用于自定义集成

命令行选项

python mcp_server.py [选项]
  • --server URL:PST API服务器URL(默认:http://localhost:5100)
  • --timeout 秒数:请求超时时间(秒)(默认:300)
  • --host 主机地址:MCP服务器主机(默认:127.0.0.1)
  • --port 端口号:MCP服务器端口(默认:8000)
  • --path 路径:stdio模式下MCP服务器访问路径(默认:/mcp)
  • --transport 模式:传输模式 - studio(stdio)、sse或http(默认:studio)
  • --debug:启用调试日志记录

启动MCP服务器

  • STDIO模式(默认)

    python3 mcp_server.py --server http://localhost:5100 --debug
    
  • SSE模式

    python3 mcp_server.py --server http://localhost:5100 --transport sse --host 0.0.0.0 --port 8000 --path /sse
    
  • HTTP模式

    python3 mcp_server.py --server http://localhost:5100 --transport http --host 0.0.0.0 --port 8000 --path /mcp
    

自定义集成配置(HTTP模式):

  • Nmap:

    $body = @{ target="scanme.nmap.org"; scan_type="-sV"; ports=""; additional_args="-T4 -Pn" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/nmap -Method POST -Body $body -ContentType "application/json"
    
  • FFUF:

    $body = @{ url="http://目标"; wordlist="C:\wordlists\common.txt"; additional_args="" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/ffuf -Method POST -Body $body -ContentType "application/json"
    
  • ProjectDiscovery:

    # Subfinder
    $body = @{ domain="example.com"; list_file=""; additional_args="-all -silent" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/subfinder -Method POST -Body $body -ContentType "application/json"
    
    # DNSX
    $body = @{ domain="example.com"; list_file=""; additional_args="-a -resp -silent" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/dnsx -Method POST -Body $body -ContentType "application/json"
    
    # Naabu
    $body = @{ host="example.com"; list_file=""; ports=""; additional_args="-silent" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/naabu -Method POST -Body $body -ContentType "application/json"
    
    # Nuclei
    $body = @{ target="http://example.com"; list_file=""; template=""; tags=""; severity=""; additional_args="-silent" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/nuclei -Method POST -Body $body -ContentType "application/json"
    
    # Katana
    $body = @{ url="http://example.com"; list_file=""; depth="3"; additional_args="-silent" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/katana -Method POST -Body $body -ContentType "application/json"
    
  • Afrog:

    $body = @{ target="http://example.com"; list_file=""; pocs=""; additional_args="" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/afrog -Method POST -Body $body -ContentType "application/json"
    
  • Ehole(指纹识别):

    $body = @{ target="http://example.com"; list_file=""; fingerprints=""; output=""; additional_args="" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/ehole -Method POST -Body $body -ContentType "application/json"
    
  • Nikto:

    $body = @{ target="http://example.com"; port=""; ssl=$false; additional_args="" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/nikto -Method POST -Body $body -ContentType "application/json"
    
  • Gobuster(目录模式):

    $body = @{ mode="dir"; url="http://example.com"; wordlist="C:\wordlists\common.txt"; additional_args="" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/gobuster -Method POST -Body $body -ContentType "application/json"
    
  • Masscan:

    $body = @{ target="192.168.1.0/24"; ports="80,443"; rate="1000"; iface=""; additional_args="" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/masscan -Method POST -Body $body -ContentType "application/json"
    
  • John(破解示例):

    $body = @{ hash_file="C:\hashes\passwd.txt"; wordlist="C:\wordlists\rockyou.txt"; format=""; mask=""; rules=$false; additional_args="" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/john -Method POST -Body $body -ContentType "application/json"
    
  • Metasploit(msfconsole -x):

    $body = @{ msf_cmd="version; exit"; rc_file=""; additional_args="" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/metasploit -Method POST -Body $body -ContentType "application/json"
    
  • Netcat:

    # 监听
    $body = @{ mode="listen"; listen_port="4444"; additional_args="" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/netcat -Method POST -Body $body -ContentType "application/json"
    # 连接
    $body = @{ mode="client"; host="127.0.0.1"; port="4444"; additional_args="" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/netcat -Method POST -Body $body -ContentType "application/json"
    
  • BBOT(递归互联网扫描器):

    # 使用预设
    $body = @{ target="example.com"; preset="web-basic"; additional_args="" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/bbot -Method POST -Body $body -ContentType "application/json"
    
    # 使用特定模块
    $body = @{ target="example.com"; modules="subfinder-enum,dnsx-resolve,nmap-portscan"; additional_args="" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/bbot -Method POST -Body $body -ContentType "application/json"
    
    # 带输出目录
    $body = @{ target="example.com"; preset="cloud-enum"; output_dir="C:\bbot_output"; additional_args="" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/tools/bbot -Method POST -Body $body -ContentType "application/json"
    
  • 通用命令:

    $body = @{ command="whoami" } | ConvertTo-Json
    Invoke-RestMethod -Uri http://localhost:5100/api/command -Method POST -Body $body -ContentType "application/json"
    

安全注意事项

  • 仅在法律授权范围内使用所有工具和功能。
  • 所有命令参数都会直接传递给底层工具;输入时需谨慎,避免注入和意外操作。
  • 执行超时默认为180秒,可以通过启动时的--timeout进行调整。

迭代计划

  • 根据PST-Bucket中的工具列表添加更多端点(例如afrogeholefscan等)。
  • 提高每个工具的参数验证和输出解析,以提高稳定性和可读性。
  • 实现复杂安全测试场景的高级工作流编排。
  • 支持自定义工具定义和用户定义的工作流。
  • 开发用于监控和配置的基于Web的管理界面。

⚠️ 免责声明:

本项目仅用于教育和道德测试目的。任何对提供的信息或工具的滥用——包括未经授权的访问、利用或恶意活动——都是严格禁止的。 作者不对任何滥用行为负责。