| name | whistle |
| description | Whistle/w2 代理抓包工具。支持规则管理、值管理、请求拦截、请求重放。当用户需要抓包、调试网络请求、设置代理规则、分析 HTTP/HTTPS 流量时使用。 |
Whistle 代理抓包工具
基于 Whistle (https://wproxy.org/whistle/) 的代理抓包和管理工具,支持 HTTP/HTTPS/HTTP2 流量分析和调试。
前置要求
- Whistle 已安装并运行在
127.0.0.1:8899
- 安装命令:
npm install -g whistle && w2 start
- HTTPS 抓包需要安装证书: 访问
http://rootca.pro/
Script Directory
Agent Execution:
SKILL_DIR = this SKILL.md file's directory
- Script path =
${SKILL_DIR}/scripts/main.py
Usage
python3 ${SKILL_DIR}/scripts/main.py status
python3 ${SKILL_DIR}/scripts/main.py rules
python3 ${SKILL_DIR}/scripts/main.py active
python3 ${SKILL_DIR}/scripts/main.py create-rule <name> [content]
python3 ${SKILL_DIR}/scripts/main.py enable <name>
python3 ${SKILL_DIR}/scripts/main.py disable <name>
python3 ${SKILL_DIR}/scripts/main.py delete <name>
python3 ${SKILL_DIR}/scripts/main.py values
python3 ${SKILL_DIR}/scripts/main.py capture [url_filter] [count]
python3 ${SKILL_DIR}/scripts/main.py proxy <url>
python3 ${SKILL_DIR}/scripts/main.py replay <url> [method]
python3 ${SKILL_DIR}/scripts/main.py enable-https
python3 ${SKILL_DIR}/scripts/main.py disable-https
python3 ${SKILL_DIR}/scripts/main.py enable-multi
python3 ${SKILL_DIR}/scripts/main.py disable-multi
Commands
状态与控制
| 命令 | 说明 |
|---|
status | 查看 Whistle 运行状态 |
enable-https | 启用 HTTPS 拦截 |
disable-https | 禁用 HTTPS 拦截 |
enable-multi | 启用多规则模式 |
disable-multi | 禁用多规则模式 |
规则管理
| 命令 | 说明 |
|---|
rules | 列出所有规则 |
active | 显示启用的规则 |
create-rule <name> [content] | 创建新规则 |
enable <name> | 启用规则 |
disable <name> | 禁用规则 |
delete <name> | 删除规则 |
值管理
抓包与请求
| 命令 | 说明 |
|---|
capture [url_filter] [count] | 获取抓包数据 |
proxy <url> | 通过代理发送请求 |
replay <url> [method] | 重放请求 |
常用规则示例
python3 ${SKILL_DIR}/scripts/main.py create-rule log-all "* log://"
python3 ${SKILL_DIR}/scripts/main.py enable log-all
python3 ${SKILL_DIR}/scripts/main.py create-rule proxy-test "example.com 127.0.0.1:8080"
python3 ${SKILL_DIR}/scripts/main.py create-rule mock-api "api.example.com/data resBody://{mockData}"
Whistle 规则语法
| 规则类型 | 示例 | 说明 |
|---|
| 代理 | example.com 127.0.0.1:8080 | 将请求代理到本地 |
| 日志 | * log:// | 记录所有请求 |
| 修改响应 | example.com resBody://{"code":0} | 修改响应内容 |
| 忽略 | example.com ignore:// | 忽略该域名 |
| 禁用缓存 | example.com disable://cache | 禁用缓存 |
| 注入 | example.com htmlPrepend://{script} | 注入 HTML |
HTTPS 证书
HTTPS 抓包需要安装 Whistle 根证书:
- 访问
http://rootca.pro/
- 下载证书
- 安装到系统信任链
输出格式
status 输出
=== Whistle 状态 ===
HTTPS拦截: True
HTTP2: True
多规则模式: False
所有规则禁用: False
规则数量: 35
rules 输出
=== 规则列表 (35 个) ===
[启用] rule-name-1
[禁用] rule-name-2
capture 输出
=== 抓包数据 (5 个请求) ===
[GET] https://example.com/api/data
状态: 200
使用场景
- 调试 API: 查看请求/响应内容
- Mock 数据: 使用规则模拟 API 响应
- 代理转发: 将线上请求代理到本地开发环境
- 性能分析: 查看请求时间、大小等信息
- 注入脚本: 注入调试工具或自定义脚本