网络分析协议服务器

Wireshark MCP是一个用于将Wireshark网络分析能力与AI系统(如Claude)集成的协议服务器,提供实时网络流量捕获、PCAP文件分析、协议信息提取和网络流摘要等功能。

  • by sarthaksiddha
  • Python
  • 本地部署
  • 32 星标
  • 更新于
在 GitHub 查看 sarthaksiddha/wireshark-mcp

使用说明

Wireshark MCP(模型上下文协议)

用于将Wireshark网络分析功能与Claude等AI系统集成的模型上下文协议(MCP)服务器。此实现提供了与Claude的直接集成,而不需要手动复制/粘贴提示。

什么是Wireshark MCP?

Wireshark MCP为AI助手通过Wireshark访问和分析网络数据包提供了一种标准化的方式。它通过实现模型上下文协议弥合了低级网络数据和高级AI理解之间的差距。

服务器提供以下工具:

  1. 捕获实时网络流量
  2. 分析现有pcap文件
  3. 提取协议特定信息
  4. 总结网络流

快速开始

安装

# Clone the repository 
git clone https://github.com/sarthaksiddha/Wireshark-mcp.git 
cd Wireshark-mcp

# Install dependencies
pip install -e .

运行MCP服务器

# Run with stdio transport (for Claude Desktop)
python mcp_server.py --stdio

# Run with SSE transport (for other MCP clients)
python mcp_server.py --host 127.0.0.1 --port 5000

配置Claude桌面

要配置Claude Desktop以使用Wireshark MCP服务器,请执行以下操作:

  1. 打开克劳德桌面
  2. 前往“设置”>“开发人员”>“编辑配置”
  3. 添加以下配置:
{
  "mcpServers": {
    "wireshark": {
      "command": "python",
      "args": [
        "/path/to/wireshark-mcp/mcp_server.py",
        "--stdio"
      ]
    }
  }
}

替换 /path/to/wireshark-mcp 使用存储库的实际路径。

可用工具

Wireshark MCP服务器提供以下工具:

  • capture_live_traffic:使用tshark捕获实时网络流量
  • analyze_pcap:分析现有的pcap文件
  • get_protocol_list:获取支持的协议列表

Claude中的示例用法

配置后,您可以使用Claude中的Wireshark MCP服务器进行以下查询:

  • “在我的系统上捕获30秒的网络流量,并向我显示发生了什么”
  • “分析我的network.pcap文件,并告诉我是否有任何可疑活动”
  • “在分析网络流量时,我可以关注哪些协议?”

主要特点

  • 数据包摘要:将大型pcap文件转换为令牌优化的摘要
  • 协议情报:通用协议(HTTP、DNS、TLS、SMTP等)的增强上下文
  • 流量跟踪:将相关数据包分组到会话流中
  • 异常突出显示:强调不寻常或可疑的模式
  • 查询模板:常见网络分析任务的预构建提示
  • 可视化生成:创建基于文本的网络模式表示
  • 多层次抽象:从原始字节到高级行为查看数据
  • web界面:基于浏览器的用户界面,便于分析和可视化
  • 代理到代理(A2A)集成:将数据包分析作为A2A兼容代理公开
  • 高级安全框架:数据保护和通信的全面安全控制
  • IP地址保护:匿名化敏感网络地址的多种策略
  • 安全通信:用于安全代理间通信的强大消息签名
  • 交叉平台的:适用于Windows、macOS和Linux

文档

基本用法

from wireshark_mcp import WiresharkMCP, Protocol
from wireshark_mcp.formatters import ClaudeFormatter

# Initialize with a pcap file
mcp = WiresharkMCP("capture.pcap")

# Generate a basic packet summary
context = mcp.generate_context(
    max_packets=100,
    focus_protocols=[Protocol.HTTP, Protocol.DNS],
    include_statistics=True
)

# Format it for Claude
formatter = ClaudeFormatter()
claude_prompt = formatter.format_context(
    context, 
    query="What unusual patterns do you see in this HTTP traffic?"
)

# Save to file for use with Claude
with open("claude_prompt.md", "w") as f:
    f.write(claude_prompt)

与克劳德一起使用

有三种主要方法可以将Wireshark MCP与Claude一起使用:

1.直接MCP集成(新)

为了与Claude Desktop无缝集成:

# Run the MCP server with stdio transport
python mcp_server.py --stdio

然后按照上面“配置Claude Desktop”一节中的说明配置Claude桌面。这种方法提供了直接集成,不需要任何复制/粘贴。

2.简单的脚本方法

无需复杂设置即可快速分析(需要复制/粘贴):

python scripts/simple_pcap_analysis.py path/to/your/capture.pcap

这将生成一个markdown文件,您可以在以下位置复制并粘贴到Claude中 克劳德·艾.

3.API集成

对于与Claude的API的程序集成:

from claude_client import ClaudeClient  # Your implementation
from wireshark_mcp import WiresharkMCP
from wireshark_mcp.formatters import ClaudeFormatter

# Process the PCAP file
mcp = WiresharkMCP("capture.pcap")
context = mcp.generate_context()

# Format for Claude
formatter = ClaudeFormatter()
prompt = formatter.format_context(context, query="Analyze this network traffic")

# Send to Claude API
client = ClaudeClient(api_key="your_api_key")
response = client.analyze(prompt)

请参阅 克劳德集成指南 API的详细说明。

需求

  • Python 3.8+
  • Wireshark/tshark已安装并位于您的PATH中
  • fastmcp Python包

贡献

欢迎投稿!特别需要帮助的领域:

  • 附加协议分析器
  • 性能优化
  • 文件和示例
  • 使用不同的数据包捕获进行测试
  • Web界面增强

看 贡献.md 了解如何做出贡献的详细信息。

许可证

此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。