mcpField
G
ghost-proxy

ghost-proxy

github.com/ghostsecurity安全4274.0k 次安装4 周前更新
代码仓库

关于 ghost-proxy

ghost-proxy 是使用 Reaper 进行应用安全测试的命令行技能。Reaper 可拦截 HTTP/HTTPS 流量,并支持搜索和检查请求与响应。

主要功能

  1. 01按范围拦截 HTTPS 流量
  2. 02记录并搜索流量
  3. 03检查原始请求和响应
  4. 04启动与停止代理

适用场景

  1. 01安全测试期间捕获应用流量
  2. 02检查请求以验证安全发现

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/ghostsecurity/skills --skill ghost-proxy

安装后在 Claude Code 中输入/ghost-proxy确认已加载。

详细介绍

Reaper MITM 代理

Reaper 是一款基于 CLI 的 MITM HTTPS 代理,用于应用安全测试。它会拦截、记录并允许检查经由代理的 HTTP/HTTPS 流量。可用它捕获实时请求/响应对,以验证安全性。

前置条件

使用任何 reaper 命令之前,请确保已安装最新版本的二进制文件:

curl -sfL https://raw.githubusercontent.com/ghostsecurity/reaper/main/scripts/install.sh | bash

除非 ~/.ghost/bin 已添加到 PATH,否则本文档中的所有 reaper 命令都应以 ~/.ghost/bin/reaper 的形式调用。

快速参考

命令用途
reaper start --domains example.com启动代理(前台运行)
reaper start --domains example.com -d启动代理(守护进程)
reaper logs显示最近捕获的条目
reaper search --method POST --path /api/*搜索捕获的流量
reaper get <id>显示完整请求和响应
reaper req <id>仅显示原始 HTTP 请求
reaper res <id>仅显示原始 HTTP 响应
reaper stop停止守护进程

启动代理

启动 reaper 并将其限制在目标域名范围内。必须至少指定一个 --domains 或 --hosts 标志。

# Intercept all traffic to example.com and its subdomains
reaper start --domains example.com

# Multiple domains
reaper start --domains example.com,api.internal.co

# Exact hostname matching
reaper start --hosts api.example.com

# Both domain suffix and exact host matching
reaper start --domains example.com --hosts special.internal.co

# Custom port (default: 8443)
reaper start --domains example.com --port 9090

# Run as background daemon
reaper start --domains example.com -d

范围行为:

  • --domains:后缀匹配。example.com 可匹配 example.com、api.example.com、sub.api.example.com
  • --hosts:精确匹配。api.example.com 仅匹配 api.example.com
  • 范围之外的流量会透明地直通,不会被记录

通过代理路由流量

配置 HTTP 客户端使用代理。默认监听地址为 localhost:8443。

# curl
curl -x http://localhost:8443 -k https://api.example.com/endpoint

# Environment variables (works with many tools)
export http_proxy=http://localhost:8443
export https_proxy=http://localhost:8443

# Python requests
import requests
requests.get("https://api.example.com/endpoint",
             proxies={"http": "http://localhost:8443", "https": "http://localhost:8443"},
             verify=False)

由于 reaper 会在启动时生成自己的 CA 证书,用于 MITM TLS 拦截,因此需要使用 -k / verify=False 标志。

查看捕获的流量

最近的条目
# Show last 50 entries (default)
reaper logs

# Show last 200 entries
reaper logs -n 200

输出列:ID、METHOD、HOST、PATH、STATUS、MS、REQ(请求正文大小)、RES(响应正文大小)。

搜索
# By HTTP method
reaper search --method POST

# By host (supports * wildcard)
reaper search --host *.api.example.com

# By domain suffix
reaper search --domains example.com

# By path prefix (supports * wildcard)
reaper search --path /api/v3/transfer

# By status code
reaper search --status 200

# Combined filters
reaper search --method POST --path /api/v3/* --status 200 -n 50
检查单个条目
# Full request and response (raw HTTP)
reaper get 42

# Request only
reaper req 42

# Response only
reaper res 42

输出为原始 HTTP/1.1 格式,包含标头和正文,适合用于分析或重放。

停止代理

reaper stop

常见工作流

验证安全问题

与 validate skill 配合使用时(可能需要与用户协作搭建测试环境):

  1. 启动 reaper,并将其限制在应用程序域名范围内
  2. 运行 reaper logs,确认正在捕获流量;通过代理路由测试请求后,至少应出现一个条目
  3. 如果没有出现条目,请确认代理设置和域名范围与目标匹配
  4. 以普通用户身份进行身份验证(或请用户进行身份验证),并以合法方式调用存在漏洞的端点
  5. 搜索捕获的请求,了解预期的请求格式
  6. 构造并发送恶意请求,以触发安全问题描述中的漏洞
  7. 检查响应,判断漏洞是否利用成功
  8. 使用 reaper get <id> 保存完整请求/响应作为证据

数据存储

所有数据都存储在 ~/.ghost/reaper/ 中:

  • reaper.db - 存储捕获条目的 SQLite 数据库
  • reaper.sock - 用于 CLI 与守护进程间 IPC 的 Unix 套接字
  • reaper.pid - 守护进程的进程 ID

每次启动时都会在内存中重新生成 CA 证书,不会持久化。

评论

支持 Markdown