HTTP探测服务器

一个基于httpx工具的HTTP/HTTPS目标探测和分析服务器,提供技术检测、HTTP/2支持检查、WebSocket检测等功能。

  • by ngothienan
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 an040702/httpx-mcp-server

使用说明

httpx MCP Server

MCP Server tích hợp công cụ httpx từ ProjectDiscovery để thực hiện reconnaissance và probing HTTP/HTTPS targets thông qua Model Context Protocol.

📋 Mô tả

Server này cung cấp một tool httpx_probe cho phép bạn sử dụng httpx để:

  • Quét và kiểm tra các URL/IP targets
  • Phát hiện công nghệ (CMS, Server, Framework)
  • Kiểm tra hỗ trợ HTTP/2, WebSocket, VHOST
  • Thu thập thông tin về status code, title, web server, IP, port
  • Tùy chỉnh các port cần scan

✨ Tính năng

  • ✅ Tech Detection: Phát hiện công nghệ sử dụng (-tech-detect)
  • ✅ HTTP/2 Support: Kiểm tra hỗ trợ HTTP/2 (-http2)
  • ✅ WebSocket Detection: Kiểm tra hỗ trợ WebSocket (-websocket)
  • ✅ VHOST Detection: Kiểm tra VHOST (-vhost)
  • ✅ Follow Redirects: Tự động đi theo redirects (-follow-redirects)
  • ✅ Custom Ports: Quét các port tùy chỉnh
  • ✅ JSON Output: Kết quả trả về dạng JSON dễ xử lý
  • ✅ Timeout Protection: Bảo vệ khỏi các scan quá lâu (5 phút)

🔧 Yêu cầu

  • Python 3.8+
  • httpx từ ProjectDiscovery đã được cài đặt và có trong PATH

Cài đặt httpx

Linux/macOS:

go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest

Windows:

go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest

Hoặc tải binary từ releases.

📦 Cài đặt

  1. Clone repository:
git clone <repository-url>
cd httpx-server
  1. Cài đặt dependencies:
pip install fastmcp

🔌 Cấu hình MCP Server cho Cursor và Claude Desktop

Cấu hình cho Cursor

  1. Mở Cursor Settings (Ctrl+, hoặc Cmd+,)
  2. Tìm đến phần MCP Servers hoặc mở file cấu hình MCP
  3. Thêm cấu hình sau vào file mcp.json (thường nằm tại ~/.cursor/mcp.json hoặc trong workspace settings):
{
  "mcpServers": {
    "httpx": {
      "command": "python",
      "args": ["server.py"],
      "cwd": "${workspaceFolder}/httpx-server"
    }
  }
}

Lưu ý:

  • cwd sử dụng biến ${workspaceFolder} để trỏ đến thư mục project trong workspace
  • Nếu project nằm trong subfolder, điều chỉnh đường dẫn tương ứng: "${workspaceFolder}/path/to/httpx-server"
  • Đảm bảo Python đã có trong PATH hoặc sử dụng đường dẫn đầy đủ đến Python interpreter

Cấu hình cho Claude Desktop

  1. Mở file cấu hình Claude Desktop:

    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json
  2. Thêm cấu hình sau vào mcpServers:

{
  "mcpServers": {
    "httpx": {
      "command": "python",
      "args": ["server.py"],
      "cwd": "~/path/to/httpx-server"
    }
  }
}

Lưu ý:

  • Thay ~/path/to/httpx-server bằng đường dẫn tương đối từ home directory của bạn
  • Hoặc sử dụng biến môi trường như $HOME/path/to/httpx-server
  • Đảm bảo đường dẫn đến server.py là chính xác

Cấu hình với Virtual Environment (Khuyến nghị)

Nếu bạn sử dụng virtual environment, cấu hình như sau:

Cursor:

{
  "mcpServers": {
    "httpx": {
      "command": "${workspaceFolder}/httpx-server/venv/bin/python",
      "args": ["server.py"],
      "cwd": "${workspaceFolder}/httpx-server"
    }
  }
}

Claude Desktop:

{
  "mcpServers": {
    "httpx": {
      "command": "~/path/to/httpx-server/venv/bin/python",
      "args": ["server.py"],
      "cwd": "~/path/to/httpx-server"
    }
  }
}

Kiểm tra cấu hình

Sau khi cấu hình:

  1. Khởi động lại Cursor/Claude Desktop
  2. Trong chat, bạn sẽ thấy tool httpx_probe có sẵn
  3. Thử gọi tool để kiểm tra:
    Sử dụng httpx_probe để scan example.com
    

Troubleshooting

  • Lỗi "command not found": Đảm bảo Python đã có trong PATH hoặc sử dụng đường dẫn đầy đủ
  • Lỗi "No module named 'fastmcp'": Cài đặt dependencies trong virtual environment hoặc global Python
  • Lỗi "httpx not found": Kiểm tra httpx đã được cài đặt và có trong PATH (xem phần Xử lý lỗi)

⚙️ Cấu hình

Nếu httpx không có trong PATH (đặc biệt trên Windows), bạn có thể hardcode đường dẫn trong server.py:

# Thay đổi dòng 12 trong server.py
HTTPX_PATH = r"C:\Users\YourUser\go\bin\httpx.exe"  # Windows
# hoặc
HTTPX_PATH = "/usr/local/bin/httpx"  # Linux/macOS

🚀 Sử dụng

Chạy MCP Server

python server.py

Tool: httpx_probe

Tham số

  • targets (List[str], bắt buộc): Danh sách URL/IP cần scan

    • Ví dụ: ["google.com", "192.168.1.1", "https://example.com"]
  • ports (str, tùy chọn): Các port cần scan, phân cách bằng dấu phẩy

    • Ví dụ: "80,443,8080,8443"
  • tech_detect (bool, mặc định: True): Bật phát hiện công nghệ (-tech-detect)

  • follow_redirects (bool, mặc định: True): Tự động đi theo redirects (-follow-redirects)

  • websocket (bool, mặc định: True): Kiểm tra hỗ trợ WebSocket (-websocket)

  • vhost (bool, mặc định: True): Kiểm tra VHOST (-vhost)

  • http2 (bool, mặc định: True): Kiểm tra hỗ trợ HTTP/2 (-http2)

  • no_fallback (bool, mặc định: False): Không fallback sang HTTP nếu HTTPS lỗi (-no-fallback)

Kết quả trả về

Kết quả là một JSON array chứa các object với các trường:

  • url: URL đầy đủ
  • ip: IP address của target
  • port: Port được phát hiện
  • status_code: HTTP status code
  • title: Tiêu đề trang web
  • webserver: Web server (Apache, Nginx, etc.)
  • tech: Mảng các công nghệ được phát hiện (nếu có)
  • http2: Có hỗ trợ HTTP/2 hay không
  • websocket: Có hỗ trợ WebSocket hay không
  • vhost: Thông tin VHOST (nếu có)

📝 Ví dụ

Ví dụ 1: Scan đơn giản một domain

httpx_probe(
    targets=["example.com"],
    tech_detect=True,
    follow_redirects=True
)

Ví dụ 2: Scan nhiều targets với port tùy chỉnh

httpx_probe(
    targets=["192.168.1.1", "192.168.1.100", "internal.company.com"],
    ports="80,443,8080,8443",
    tech_detect=True,
    http2=True
)

Ví dụ 3: Scan với tất cả tính năng

httpx_probe(
    targets=["target.com", "subdomain.target.com"],
    ports="80,443,8000,8080,8443",
    tech_detect=True,
    follow_redirects=True,
    websocket=True,
    vhost=True,
    http2=True,
    no_fallback=False
)

Ví dụ 4: Scan nhanh không tech detection

httpx_probe(
    targets=["quick-scan.com"],
    tech_detect=False,
    websocket=False,
    vhost=False,
    http2=False
)

🔍 Output mẫu

[
  {
    "url": "https://example.com:443",
    "ip": "93.184.216.34",
    "port": 443,
    "status_code": 200,
    "title": "Example Domain",
    "webserver": "nginx",
    "http2": true,
    "tech": ["nginx", "PHP"]
  }
]

⚠️ Lưu ý

  • Timeout mặc định là 5 phút cho mỗi lần scan
  • Kết quả được trả về dạng JSON, dễ dàng xử lý và tích hợp
  • Các trường None hoặc rỗng sẽ được loại bỏ khỏi output để tiết kiệm context
  • Đảm bảo httpx đã được cài đặt và có trong PATH trước khi sử dụng

🐛 Xử lý lỗi

Nếu gặp lỗi "Không tìm thấy lệnh 'httpx'":

  1. Kiểm tra httpx đã được cài đặt: httpx -version
  2. Kiểm tra PATH: which httpx (Linux/macOS) hoặc where httpx (Windows)
  3. Hardcode đường dẫn trong server.py nếu cần

📚 Tài liệu tham khảo

📄 License

MIT License