mcpField
C
caido-mode

caido-mode

github.com/caido安全2852.7k 次安装11 周前更新
代码仓库

关于 caido-mode

基于 Caido API 的命令行 Skill,用于通过 HTTP 历史记录开展安全测试并移交请求。它规范代理 curl 探测、认证快照和命名 Replay 会话的使用。

主要功能

  1. 01搜索和查看 HTTP 历史
  2. 02导出含认证信息的 curl 配置
  3. 03通过 Caido 代理发送探测
  4. 04创建命名 Replay 会话
  5. 05管理多个实例的凭据

适用场景

  1. 01使用历史认证请求探测端点
  2. 02让测试流量保留在 Caido 历史中
  3. 03通过 Replay 向操作人员移交请求
  4. 04切换已配置的 Caido 实例

安装

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

$npx skills add https://github.com/caido/skills --skill caido-mode

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

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

.gitignore
caido-client.ts
package-lock.json
package.json
README.md
lib/
client.ts
graphql.ts
output.ts
types.ts
lib/commands/
findings.ts
info.ts
intercept.ts
management.ts
matchreplace.ts
replay.ts
requests.ts
test/
exportcurl.test.ts
matchreplace.test.ts
rawedit.test.ts

详细介绍

Caido 模式技能

一个基于 Caido API(使用官方 @caido/sdk-client)的 CLI,用于由 HTTP 历史记录驱动的测试。工具位于 ~/.claude/skills/caido-mode/caido-client.ts;每条命令都是 npx tsx caido-client.ts <command>,除非另有说明,均输出 JSON。

如何操作(请先阅读)

有两种不同的模式:

  1. 测试 → 使用 curl,始终通过 Caido 代理。 在历史记录中找到一条经过身份验证的真实请求,将其身份验证信息缓存到可复用的 curl 配置中(忠实静态保存其标头和 Cookie),然后使用 curl -K auth.cfg "$BASE/path" 进行探测。所有流量都必须经过 Caido(配置文件中包含代理设置),这样每个请求都会进入 HTTP 历史记录。
  2. 交接 → 使用重放会话和集合。 只有在将一个或一组请求交给用户时,才将其创建为命名集合中的命名重放会话。

硬性规则:

  • 所有流量都必须经过 Caido——高流量暴力破解/模糊测试除外。 绝不要直接对单个目标请求运行 curl;始终通过 Caido 代理(生成的配置会处理此事;否则添加 -x <proxy>)。**唯一例外:**不要让暴力破解/模糊测试工具(如 ffuf)或任何一次 100+ 个请求的批量请求经过 Caido 代理——这会使 HTTP 历史记录膨胀。请直接运行(不加 -x),然后将任何有价值的命中带回 Caido(通过代理重新发送/提升到 Replay),以便调查和交接。
  • 使用 curl 进行测试。 不要为探测启动重放会话——重放会话仅用于交接。
  • 要向操作者展示请求,请将其发送到 Replay。 每当你想让操作者看到某个特定请求时,都要为其创建一个命名重放会话(如果不止一个请求,则放入命名集合)——这样他们才能在 Caido 中检查并重新运行请求。通过 curl 测试的请求,只有提升到 Replay 后,操作者才能使用它(使用 create-session <id> --name …,或对构造的请求使用 send-raw … --name …)。
  • 将身份验证信息缓存到文件中,不要反复粘贴。 每个目标使用一次 export-curl --config;之后引用配置文件即可。不要在每条命令中(或反复在上下文中)输出 Cookie/JWT。
  • 如果要给操作者一条可运行的命令,必须提供完整且独立的 curl 命令(通过 export-curl 将所有标头内联)——适用于 PoC 或他们将在 Caido 之外运行的命令。-K 配置仅供你内部测试使用;绝不要交给他们一条 curl -K /tmp/… 命令。
  • 重放会话必须命名,编辑会话时必须明确指定名称。
  • 交接多个请求时使用集合;通过名称而非 ID引用会话/集合。

主要工作流(默认按此执行)

# 1. Find a base request that already has the auth/cookies you need.
npx tsx caido-client.ts search 'req.host.cont:"target.com" AND req.path.cont:"/api/user"' --compact
#    → 8431  200  GET target.com/api/user/me

# 2. ONCE per target: cache its auth into a reusable curl config.
npx tsx caido-client.ts export-curl 8431 --config
#    → writes /tmp/caido/target.com/auth.cfg — a FAITHFUL STATIC snapshot:
#      proxy + insecure + compressed + ALL the request's auth/identity headers
#      (cookies, Authorization, Origin/Referer, X-*, Sec-*, app-specific headers)
#      and prints BASE + the captured header list

# 3. Test with curl. -K carries the proxy + auth, so it goes through Caido into history.
BASE=https://target.com
curl -K /tmp/caido/target.com/auth.cfg "$BASE/api/user/999"                 # IDOR
curl -K /tmp/caido/target.com/auth.cfg -X POST "$BASE/api/profile" \
     -H 'Content-Type: application/json' --data-binary @/tmp/caido/target.com/body.json

可以自由重复步骤 3——成本很低,所有操作都在 Caido 中进行,而且庞大的身份验证数据块会留在文件里。使用 search 'req.host.cont:"target.com"' --compact 确认探测请求已进入 Caido。

按原样发送路径

测试路径遍历/路径规范化(../、/..、/./、编码变体)时,传入 curl --path-as-is——否则 curl 会在客户端发送前折叠 ../ 和 /./,导致服务器看不到载荷,测试会在不知情的情况下通过。保持路径原样:

curl --path-as-is -K /tmp/caido/target.com/auth.cfg "$BASE/api/../../../etc/passwd"

(同样,如果 URL 中包含你不希望 curl 解读的 [ ] { },请添加 -g/--globoff。)

配置是忠实的静态快照(重要)

export-curl --config 会捕获基础请求中的所有身份验证/身份标识标头(而非经过筛选的子集),并将 Cookie 以内联方式静态写入。这两个经过深刻教训后作出的刻意选择:

  • 所有标头,而非允许列表。 现代应用会根据特定于应用的标头来控制授权,而这些标头无法预先推断——x-goog-ext-*、X-Browser-Validation、X-Client-Data、Origin、Referer、X-Same-Domain、Sec-* 等。范围狭窄的允许列表会悄悄丢弃这些标头,导致难以诊断的 403/PERMISSION_DENIED。现在,配置会与实际授权该请求的内容保持一致。只会丢弃真正逐请求变化/易变的标头:Host、Content-Length、Content-Type、Connection、Accept-Encoding(curl 会为每个请求管理这些标头)。
    • ⚠ 由于 Content-Type 会被丢弃,每次 POST/PUT/PATCH 都必须自行传入: curl -K auth.cfg -X POST "$BASE/path" -H 'Content-Type: application/json' --data-binary @body。 请使用端点要求的准确 Content-Type(例如,Google batchexecute 需要 application/x-www-form-urlencoded;charset=UTF-8)——错误或缺少该标头是常见的 400/403 原因。curl 会自行设置 Content-Length;不要添加它。
  • 静态 Cookie,不使用 Cookie jar。 默认不使用 cookie-jar,因此 curl 不会将响应中轮换后的 Set-Cookie 写回并覆盖已捕获的有效 Cookie(Google 等服务器会在每次响应后轮换 Cookie,包括错误响应——回写 Cookie jar 会让会话逐渐失效)。需要跟进轮换?使用 export-curl <id> --config --cookie-jar 启用。

要丢弃特定标头:使用 --exclude <name>(可重复指定)。要完全省略 Cookie(例如 Match & Replace 规则会注入身份验证信息时):使用 --exclude cookie。

其他约定
  • 每个目标的临时目录: /tmp/caido/<host>/ 用于存放 auth.cfg、请求体文件和备注。
  • $BASE: 设置一次 BASE=https://<host>;请求写作 "$BASE/path"。
  • 请求体存入文件: 将较大/复杂的请求体保存一次,并使用 --data-binary @body.json 发送 (这是 --data-binary 的正确用法——发送字节精确的请求体)。由于配置中省略了 Content-Type,每个请求都要添加 -H 'Content-Type: …'。
  • 延迟刷新: 快照是静态的,因此当请求开始返回 401/403(令牌过期/Cookie 失效)时,重新运行 export-curl <fresh-id> --config 以重新生成快照,然后重试。
  • CSRF: 匹配的 X-CSRF*/双重提交标头会自动捕获。对于每次操作都会轮换的令牌,请获取新令牌:T=$(curl -sK auth.cfg "$BASE/csrf" | jq -r .token)。
  • 由代理注入身份验证信息(替代方案): 不使用配置,而是通过 Match & Replace 规则为所有代理流量注入 Authorization/Cookie——这样,curl -x <proxy> -k "$BASE/path" 无需标头。请参阅 Match & Replace。
向用户提供命令

要在 Caido 内向操作人员展示请求,请将请求发送到 Replay(见下文“Replay sessions”)——这是默认方式。本节适用于另一种情况:向他们提供可运行的命令(PoC,或在 Caido 外运行的命令)。此时始终提供完整且独立的 curl 命令——内联包含每个标头,不使用 -K:

npx tsx caido-client.ts export-curl 8431      # full curl, all headers inline (portable PoC)

如需提供可在任何地方运行的便携 PoC,请删除 -x/-k;只有在用户需要通过自己的 Caido 运行时才保留它们。绝不要向用户提供 curl -K /tmp/... 命令——该文件是你自己的。


代理

所有 curl 测试都必须通过 Caido 的代理进行。代理地址默认为 Caido URL(代理和 API 共用一个地址)。请随时查询或确认:

npx tsx caido-client.ts auth-status     # prints "proxy": "http://localhost:8080"

export-curl --config 会将代理写入配置(proxy = "…")。临时使用 curl 时,请自行添加 -x <proxy> -k。只有当代理监听地址与 API URL 不同时,才覆盖代理地址——使用 setup --proxy <addr> 或 export CAIDO_PROXY=<addr>。

从 auth-status 获取代理地址(proxy/activeUrl 字段)——不要直接解析 secrets.json 。 现在的认证按 URL 区分:地址保存在 .caido.default / .caido.instances 下,而不是 .caido.url。


身份验证设置

# One-time: create a PAT in Caido (Dashboard → Developer → Personal Access Tokens), then:
npx tsx caido-client.ts setup <your-pat>
npx tsx caido-client.ts setup <pat> http://192.168.1.100:8080            # non-default instance
npx tsx caido-client.ts setup <pat> http://localhost:8080 --proxy http://localhost:8080

# Or env vars
export CAIDO_PAT=caido_xxxxx
export CAIDO_URL=http://localhost:8080
export CAIDO_PROXY=http://localhost:8080   # only if the proxy differs from the URL

npx tsx caido-client.ts auth-status        # check (also prints the proxy)
npx tsx caido-client.ts health             # verify instance is up

setup 通过 SDK 的设备代码流程验证 PAT(PAT 会自动批准),然后将 PAT + 访问令牌(+ 代理) 缓存到 ~/.claude/config/secrets.json。后续运行会使用缓存的令牌;即使没有 PAT,有效的缓存令牌也能正常工作。

多个 Caido 实例

凭据按实例 URL 区分——同一台机器上的两个实例互不覆盖。 setup <pat> <url> 会将该实例保存到对应的 URL 下(并将其设为当前默认实例); 设置第二个 URL 时会新增一条记录,而不是覆盖第一条。

npx tsx caido-client.ts setup <pat-a> http://localhost:8080
npx tsx caido-client.ts setup <pat-b> http://localhost:8081     # added, not overwritten
npx tsx caido-client.ts auth-status                              # lists configuredInstances + activeUrl

当前实例的选择顺序为 CAIDO_URL 环境变量 → 已保存的默认实例 → http://localhost:8080。可以使用 CAIDO_URL 按 shell/Agent 选择实例(支持并发,不存在需要竞争的共享“当前实例”),例如: CAIDO_URL=http://localhost:8081 npx tsx caido-client.ts recent。CAIDO_PAT/CAIDO_PROXY 环境变量 会覆盖当前实例保存的值。


搜索 HTTP 历史记录(HTTPQL)

npx tsx caido-client.ts search 'req.method.eq:"POST" AND resp.code.eq:200' --compact
npx tsx caido-client.ts search 'req.host.cont:"api"' --limit 50
npx tsx caido-client.ts search 'req.host.cont:"api"' --asc --limit 50   # oldest first (rarely wanted)
npx tsx caido-client.ts recent --compact            # newest requests, one line each
npx tsx caido-client.ts get 8431 --compact          # full details (JSON) when you need them
npx tsx caido-client.ts get-response 8431 --compact
npx tsx caido-client.ts raw 8431 --out /tmp/caido/target.com/body.json   # dump bytes (e.g. a body)
  • 默认情况下,search 按最新优先排序(按请求 ID 降序)。因此,--limit N 会返回最新的 N 个匹配结果。只有在确实需要从最旧的结果开始时,才传入 --asc(别名 --oldest)。
  • 要获取“最新的匹配 X”,只需运行 search '<filter>' --limit N——不要先用较大的 --limit 拉取结果,再在客户端重新排序(例如 jq 'sort_by(.createdAt) | reverse')。这样只会对已获取的截断结果排序,因此任何比第 N 个结果更新的请求都会被悄然忽略——你会误把过时流量当作最新结果。让 Caido 负责排序。
  • recent 始终按最新优先排序,但不接受任何筛选条件;要获取符合筛选条件的最新结果,请使用 search --limit N。
  • --compact → 每个请求显示一行精简信息(id status METHOD host/path)。
  • 浏览时优先使用 search/recent --compact;选定请求后再使用 get/export-curl。

完整查询语言请参阅下文的HTTPQL 参考。


重放会话——仅用于交接

在将请求交给用户时使用这些功能。常规测试使用 curl(如上所述),而不是会话。 根据原始请求创建的会话会**自动将标头行结束符规范化为 CRLF **——交接会话绝不会使用裸 LF(\n)行结束符。

# Create a NAMED session from a history request (name is REQUIRED).
npx tsx caido-client.ts create-session 8431 --name "IDOR /api/user/:id"
npx tsx caido-client.ts sessions                                   # list (alias: replay-sessions)
npx tsx caido-client.ts rename-session "IDOR /api/user/:id" "IDOR - confirmed"
npx tsx caido-client.ts move-session "IDOR - confirmed" "Vuln chain - IDOR to ATO"

# Build a handoff session from a raw request file (CRLF auto-normalized):
npx tsx caido-client.ts send-raw --host target.com --raw @/tmp/req.txt --name "crafted repro"
编辑会话时必须声明名称处理方式

如果用户要求你在 Replay 内部测试,请使用 edit / edit-session。由于编辑会改变会话内容,必须声明如何处理其名称——准确传入以下参数之一: --no-name-change(--nonach)或 --new-name "<name>":

npx tsx caido-client.ts edit 8431 --path /api/user/999 --name "IDOR victim 999"        # new session
npx tsx caido-client.ts edit-session "IDOR victim 999" --body '{"role":"admin"}' --nonach --compact
npx tsx caido-client.ts edit 8431 --path /api/admin --session "IDOR victim 999" --new-name "priv-esc"

edit 会保留原始请求中的 Cookie/认证信息;它支持 --method、--path、 --set-header、--remove-header、--body(自动设置 Content-Length)、--replace <from>:::<to>,以及 连接覆盖参数(--sni、--connect-host,……)。

检查现有重放标签页

如果 Caido 中已经打开重放标签页,并且你想基于其当前状态操作,请按名称或 ID查找它(无需重新创建):

npx tsx caido-client.ts get-session "IDOR victim 999" --compact      # session + its active entry
npx tsx caido-client.ts replay-entries "IDOR victim 999" --limit 20  # request/response history in the tab
npx tsx caido-client.ts replay-entries "IDOR victim 999" --raw --compact   # include raw bytes

session-entries 是 replay-entries 的别名。使用这些命令读取标签页中的内容;要向其中发送修改后的请求,请使用 edit-session(见上文)。


集合 — 大量使用

集合用于整理会话,方便交接。**创建会话前,先列出现有集合,再决定会话归属。**集合必须命名,且不会自动创建。

npx tsx caido-client.ts collections                         # query first
npx tsx caido-client.ts create-collection "Swagger - petstore.yaml"
npx tsx caido-client.ts rename-collection "old name" "new name"
情况集合决策
为用户重现一个请求默认集合 — 不要创建新集合。为会话命名,并告知用户该名称。
JS 文件中每个端点对应一个重放标签页新建集合 JS File Endpoints。
Swagger 规范中每个端点对应一个重放标签页新建集合 Swagger - <filename>。
针对某个漏洞的多请求链新建集合 Vuln chain - <description>,步骤命名为 1. …、2. …。
/api/v2 下的所有端点新建集合 /api/v2/*。

按名称传入集合;CLI 会解析它(如果集合不存在,会提示你先创建):

npx tsx caido-client.ts create-session 8431 --name "1. login" --collection "Vuln chain - IDOR to ATO"

回复时,请使用集合和会话的名称 — 绝不要使用 ID。


匹配与替换 — 自动重写流量

匹配与替换(Caido 内部称为 “Tamper” 规则)会在请求/响应经过 Caido 时自动重写。最实用的用法是:在代理处注入身份验证信息,这样你的 curl 命令就无需携带它 — 添加一条规则,在每个代理请求中设置 Authorization,然后 curl -x <proxy> -k "$BASE/path" 就能通过身份验证,无需使用 -K/请求头。

一条规则由一个区段(要处理的部分)× 一个操作 × 一个匹配器 × 一个替换器组成,并可选配条件(HTTPQL 范围)和来源:

部分可选项
区段req:req-method req-path req-query req-body req-first-line req-header req-all req-sni · resp:resp-body resp-status resp-first-line resp-header resp-all · ws:ws-up ws-down
操作raw(在区段内匹配)· update/add/remove(仅限请求头和查询参数,按名称操作)· 仅 update 适用于方法/状态码
匹配器--match-value <str> · --match-regex <re> · --match-full(整个区段)· --match-name <n>(用于请求头/查询参数的 update/add/remove)
替换器--replace <term>(字面值;允许 "")· --workflow <id>(运行工作流)
条件--condition '<httpql>' — 仅在请求匹配时应用(例如,仅针对一个主机)
来源--sources INTERCEPT,REPLAY,… — 指定适用的流量来源

有四点注意事项,均已为你设置默认值:

  • **新规则创建时处于禁用状态。**使用 toggle-mr-rule <id> --on 启用。
  • 默认集合为 Caido 的 “Default Collection”(使用 --collection <name|id> 覆盖)。
  • 默认来源为 INTERCEPT(代理流量),与 Caido 一致。添加 --sources 以扩大范围。
  • **JS 目标 — 根据要匹配的内容选择匹配器。**对于稳定的字面值(字符串常量、JSON 键、固定 API 路径),可以使用 --match-value。匹配缩小混淆后的标识符附近的内容时,请使用 --match-regex:符号名称会随每次 bundle 部署而变化(例如 _.ex → _.Ww),因此字面值规则会悄无声息地停止匹配,且不会报错。应使用周围的字符串字面值、已知函数名、固定 JSON 键等结构稳定的相邻内容来锚定正则表达式,而不是混淆后的标识符本身。

提交前先预览:test-mr-rule 可将规则应用于原始请求,而不会创建任何内容 — 用它确认规则的效果符合预期。

# Preview: would this add the header correctly?
npx tsx caido-client.ts test-mr-rule --section req-header --operation add \
  --match-name X-Test --replace hi --raw 'GET / HTTP/1.1\r\nHost: t.com\r\n\r\n'

# Inject auth on all proxied requests to one host (then enable it)
ID=$(npx tsx caido-client.ts create-mr-rule --section req-header --operation add \
  --match-name Authorization --replace "Bearer eyJ…" \
  --condition 'req.host.eq:"target.com"' --name "auth inject" | jq -r '.created.id')
npx tsx caido-client.ts toggle-mr-rule "$ID" --on

# Other patterns
npx tsx caido-client.ts create-mr-rule --section req-header --operation remove \
  --match-name If-None-Match --sources REPLAY --name "drop INM"           # strip a header
npx tsx caido-client.ts create-mr-rule --section req-body --match-regex '"admin":false' \
  --replace '"admin":true' --name "force admin"                            # body regex
npx tsx caido-client.ts create-mr-rule --section resp-status --replace 403 --name "fake 403"  # response

npx tsx caido-client.ts mr-rules                # list rules (+ enabled state)
npx tsx caido-client.ts toggle-mr-rule <id> --off
npx tsx caido-client.ts delete-mr-rule <id>

使用 mr-collections、create-mr-collection、rename-mr-collection、delete-mr-collection 管理集合;使用 move-mr-rule <id> <collection> 移动规则;update-mr-rule <id> … 可重新指定规则(使用与创建规则相同的标志);使用 rename-mr-rule <id> <name> 重命名规则。


输出控制(适用于 get、get-response、replay、edit、send-raw、edit-session)

标志描述
--max-body <n>响应正文的最大行数(默认值为 200,0 = 不限)
--max-body-chars <n>正文的最大字符数(默认值为 5000,0 = 不限)
--no-request从输出中省略原始请求
--headers-only仅输出标头,不输出正文
--compact简写:--no-request --max-body 50 --max-body-chars 5000

HTTPQL 参考

Caido 的查询语言,用于搜索 HTTP 历史记录。

重要:字符串值必须加引号;整数不需要。

重要:HTTPQL 没有 NOT 运算符。请改用否定运算符变体:

  • ncont(不包含)、nlike、nregex、ne(不等于)
  • 错误:NOT req.path.cont:"/admin" — 正确:req.path.ncont:"/admin"
命名空间和字段
命名空间字段类型描述
reqextstring文件扩展名(包含 .)
reqhoststring主机名
reqmethodstringHTTP 方法(大写)
reqpathstringURL 路径
reqquerystring查询字符串
reqrawstring完整的原始请求
reqportint端口号
reqlenint请求正文长度
reqcreated_atdate创建时间戳
reqtlsbool是否为 HTTPS
resprawstring完整的原始响应
respcodeint状态码
resplenint响应正文长度
resproundtripint往返时间(毫秒)
rowidint请求 ID
source-special"intercept"、"replay"、"automate"、"workflow"
preset-special过滤器预设引用
运算符
  • 字符串: eq、ne、cont、ncont、like、nlike、regex、nregex
  • 整数: eq、ne、gt、gte、lt、lte
  • 布尔值: eq、ne
  • 逻辑: AND、OR,使用括号进行分组
示例
req.method.eq:"POST" AND resp.code.eq:200       # POSTs with 200s
req.host.cont:"api" OR req.path.cont:"/api/"    # API traffic
"password" OR "secret" OR "api_key"             # bare string searches req AND resp raw
resp.code.gte:400 AND resp.code.lt:500          # 4xx
resp.len.gt:100000                              # large responses (data exposure)
req.path.regex:"/(login|auth|signin|oauth)/"    # auth endpoints
source:"replay" OR source:"intercept"           # tool-generated vs proxied traffic
req.created_at.gt:"2024-01-01T00:00:00Z"        # date filter
req.path.ncont:"/static"                        # exclude (no NOT keyword)
preset:"My Filter"                              # saved filter preset

其他功能(参考)

发现项 — 显示在 Caido 的 Findings 选项卡中
npx tsx caido-client.ts findings --limit 50
npx tsx caido-client.ts create-finding 8431 --title "IDOR on /api/user/:id" \
  --description "Reads other users' profiles by changing id" --reporter "rez0" --dedupe-key "idor-user"
npx tsx caido-client.ts update-finding <id> --title "…" --description "…"
作用域 / 过滤器预设 / 环境
npx tsx caido-client.ts create-scope "Target" --allow "*.target.com" --deny "*.cdn.target.com"
npx tsx caido-client.ts create-filter "API 4xx" --query 'req.path.cont:"/api/" AND resp.code.gte:400' --alias "api4xx"
npx tsx caido-client.ts search 'preset:"API 4xx"' --compact
npx tsx caido-client.ts create-env "IDOR-Test"; npx tsx caido-client.ts env-set <env-id> victim_id "user_999"
模糊测试 / 拦截 / 项目 / 任务 / 信息
npx tsx caido-client.ts create-automate-session 8431   # configure payloads in UI, then: fuzz <session-id>
npx tsx caido-client.ts intercept-status | intercept-enable | intercept-disable
npx tsx caido-client.ts projects ; npx tsx caido-client.ts viewer ; npx tsx caido-client.ts plugins

完整命令参考

每个命令都运行 npx tsx caido-client.ts <command>。会话/集合可使用名称或 ID;除非另有说明,输出均为 JSON。运行 --help 查看完整标志列表。

命令功能
历史记录与测试
search <httpql>搜索历史记录,按时间从新到旧排序。--limit --after --ids-only --asc/--oldest --compact
recent获取最新请求。--limit --compact
get <id> / get-response <id>完整请求 / 仅响应(输出控制标志)
raw <id>转储字节级精确的原始请求。--out <file> --response
export-curl <id>完整且独立的 curl 命令(供用户使用)
export-curl <id> --config可重复使用的 -K 配置——忠实静态快照,包含所有身份验证标头和内联 Cookie(内部使用)。--out <file> · --cookie-jar(跟随轮换)· --exclude <h>
发送 / 编辑
replay <id> --name <n>重放到新的命名会话中。--raw --collection 及连接覆盖选项
send-raw --host <h> --raw <s|@file|-> --name <n>通过新的命名会话发送原始请求。--port --tls/--no-tls --collection
edit <id>编辑并发送到重放中。--method --path --set-header --remove-header --body --replace --session --name/--new-name/--nonach --collection
edit-session <name|id>从会话的当前条目编辑并发送(需要 --nonach 或 --new-name)
重放标签页查询
get-session <name|id>会话及当前条目。--compact
replay-entries <name|id>标签页中的请求历史(别名 session-entries)。--limit --raw
会话
create-session <id> --name <n>根据请求创建新的命名会话。--collection
rename-session <name|id> <new> · move-session <s> <collection>重命名 / 移动
sessions(别名 replay-sessions)· delete-sessions <id,id,…>列出 / 删除
集合
collections(别名 replay-collections)列出集合
create-collection <name> · rename-collection <c> <new> · delete-collection <name|id>创建 / 重命名 / 删除
模糊测试create-automate-session <id> · fuzz <session-id>(在 UI 中配置负载)
发现项findings · get-finding <id> · create-finding <id> --title … · update-finding <id>
范围scopes · create-scope <name> --allow --deny · update-scope <id> · delete-scope <id>
筛选器filters · create-filter <name> --query [--alias] · update-filter <id> · delete-filter <id>
环境envs · create-env <name> · env-set <env> <var> <val> · select-env [id] · delete-env <id>
项目projects · select-project <id>
任务tasks · cancel-task <id>
托管文件hosted-files · delete-hosted-file <id>
拦截intercept-status · intercept-enable · intercept-disable
匹配与替换mr-rules · mr-collections · create-mr-rule --section … [--operation] [--match-*] [--replace/--workflow] [--name --collection --condition --sources] · test-mr-rule --raw … --section …(预览,不执行操作)· toggle-mr-rule <id> --on|--off · rename-mr-rule <id> <n> · move-mr-rule <id> <coll> · update-mr-rule <id> … · delete-mr-rule <id> · create-mr-collection <n> · rename-mr-collection <c> <n> · delete-mr-collection <c>
信息 / 身份验证viewer · plugins · health · setup <pat> [url] [--proxy] · auth-status

架构

基于 @caido/sdk-client v0.2.0+ 构建。不使用原始 fetch——使用高级 SDK 方法,以及 client.graphql.query/mutation 和 gql 文档来实现 SDK 未提供的少数功能。

caido-client.ts          # CLI entry — arg parsing + dispatch
lib/
  client.ts              # SDK Client singleton, SecretsTokenCache, auth, resolveProxy
  graphql.ts             # gql docs for features not in the SDK
  output.ts              # raw formatting (truncation, headers-only, raw→curl)
  types.ts               # OutputOpts
  commands/
    requests.ts          # search, recent, get, get-response, raw, export-curl (+ --config)
    replay.ts            # replay, send-raw, edit, sessions, collections (CRLF-normalized), automate
    findings.ts          # findings
    management.ts        # scopes, filters, environments, projects, hosted-files, tasks
    intercept.ts         # intercept status/enable/disable
    matchreplace.ts      # match & replace (tamper) rules — buildTamperSection + commands
    info.ts              # viewer, plugins, health, setup, auth-status

Claude 使用说明(检查清单)

  1. 始终通过 Caido 使用 curl 测试——代理必须位于请求链路中(配置会处理这一点;否则使用 -x <proxy>)。例外:暴力破解/模糊测试(ffuf)或一次发送 100 个以上请求时,应直接发送,以免 HTTP 历史记录膨胀;再将有价值的结果带回 Caido。
  2. 缓存一次认证信息:export-curl <id> --config → /tmp/caido/<host>/auth.cfg(完整保留所有认证标头和内联 Cookie 的静态快照)。使用 curl -K auth.cfg "$BASE/path" 测试。
  3. 按需刷新——仅在遇到 401/403/登录重定向时,根据新请求重新生成配置。
  4. 向用户提供完整、自包含的 curl 命令(export-curl <id>);绝不要只给 -K 命令。
  5. **使用 --compact 浏览;**仅对要使用的请求执行 get/export-curl。
  6. 向操作员展示请求时,将请求发送到 Replay(命名会话)。Replay 仅用于交接;必须命名。集合会被大量使用,并按名称引用。
  7. 编辑会话时,必须使用 --nonach 或 --new-name。
  8. 为所有真实发现创建发现项。
  9. HTTPQL 中绝不要使用 NOT——使用 ne/ncont/nlike/nregex。

操作说明(Shell 易踩问题)

  • 不要在 while/for 循环中批量调用 CLI。 某些 Shell 会在循环子 Shell 中清除 PATH,导致 head/python3 等命令变成“command not found”,循环主体会静默失败(看起来像是会话没有创建)。请将每个 send-raw/create-session 作为单独的顶层命令运行,或使用单独的 bash 脚本并显式执行 export PATH=…。
  • search --ids-only 返回的是 JSON 数组(["123"]),而非单个 ID——重复使用前需取出其中的值,例如:ID=$(… --ids-only | jq -r '.[0]')。
  • sessions/collections 现在会列出所有内容(采用分页,不再只列出第一页),因此新创建的项目总会显示。若需要较短的列表,可用 --limit N 限制数量。

错误处理

  • 认证错误 → auth-status,重新运行 setup <pat>(或设置 CAIDO_PAT)。
  • curl 遇到 401/403/登录重定向 → 令牌已过期;根据新请求刷新配置。
  • curl 无法通过代理连接 → 使用 auth-status 确认代理;Caido 必须正在运行。
  • 连接被拒绝/尚未就绪 → Caido 尚未启动或仍在启动;检查 health。

评论

支持 Markdown