Communitygithub.com

Caido 模式技能

基於官方 `@caido/sdk-client` 套件,提供 Caido API 的完整 CLI 覆蓋,用於 HTTP 歷史記錄、重放、範圍、環境變數等測試操作。

Caido 模式技能 是什麼?

此技能為 Caido Web 安全測試平台提供一個功能完整的命令列介面 (CLI),使 AI 代理能夠直接與 Caido 的 API 互動,無需手動操作 UI。它利用官方 `@caido/sdk-client` 套件,支援廣泛的測試工作流程,包括 HTTP 歷史記錄的高級搜尋(使用 HTTPQL)、請求和響應的檢索與重放、以及通過「編輯 (edit)」功能在保留身份驗證 cookie 的同時修改請求,這對於授權不當(IDOR)測試至關重要。使用者可以管理重放會話和集合、定義測試範圍、保存篩選器預設、儲存環境變數、建立安全發現、監控任務以及切換專案。該技能透過個人存取權杖 (PAT) 處理身份驗證,該權杖會快取到 `~/.agents/config/secrets.json`,實現無縫的 CLI 工作階段。所有命令都輸出 JSON,使其易於解析以及整合到 AI 驅動的自動化工作流程中。

相容平台✓Claude Code~Codex CLI✓Cursor✓OpenCode
npx skills add Aceproulx/claude-skills

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

Caido 模式技能 是做什麼的?

概觀

基於官方 @caido/sdk-client 套件,提供 Caido API 的完整 CLI 覆蓋。涵蓋:

  • HTTP 歷史記錄 - 使用 HTTPQL 搜尋、檢索、重放、編輯請求
  • 重放與會話 - 會話、集合、條目、模糊測試
  • 範圍 - 建立和管理測試範圍(允許清單/拒絕清單模式)
  • 篩選器預設 - 儲存和重用 HTTPQL 篩選器預設
  • 環境變數 - 儲存測試變數(受害者 ID、權杖等)
  • 發現項目 - 建立、列出、更新安全發現
  • 任務 - 監控和取消背景任務
  • 專案 - 在測試專案之間切換
  • 託管檔案 - 管理由 Caido 提供服務的檔案
  • 攔截 - 以程式方式啟用/停用請求攔截
  • 外掛程式 - 列出已安裝的外掛程式
  • 匯出 - 將請求轉換為用於概念驗證 (PoC) 的 curl 命令
  • 健康狀態 - 檢查 Caido 實例的狀態

所有流量都會經過 Caido,因此它會出現在 UI 中以供進一步分析。

為什麼採用此模式?

Cookie 和驗證權杖可能很大 - 階段 Cookie、JWT、CSRF 權杖很容易達到 1-2KB。與其手動複製貼上:

  1. 在 Caido 的 HTTP 歷史記錄中找到一個已經擁有有效驗證的原始請求
  2. 使用 edit 只修改你需要的部分(路徑、方法、主體),同時保持所有驗證標頭完整
  3. 發送它 - 響應將在保留完整上下文的同時返回

驗證設定

設定(一次性)

  1. 開啟 儀表板 → 開發者 → 個人存取權杖
  2. 建立一個新的權杖
  3. 執行:
npx tsx ~/.agents/skills/caido-mode/caido-client.ts setup <your-pat>

# 非預設 Caido 實例
npx tsx ~/.agents/skills/caido-mode/caido-client.ts setup <pat> http://192.168.1.100:8080

# 或改為設定環境變數
export CAIDO_PAT=caido_xxxxx

setup 命令會透過 SDK 驗證 PAT(SDK 會將其交換為存取權杖),然後將 PAT 和快取的存取權杖都儲存到 ~/.agents/config/secrets.json。後續執行會直接載入快取的權杖,即使 PAT 不存在,有效的快取權杖也可以被使用。

檢查狀態

npx tsx ~/.agents/skills/caido-mode/caido-client.ts auth-status

驗證如何運作

SDK 在內部使用裝置授權流程 — PAT 會自動批准它並接收一個存取權杖和一個重新整理權杖。一個自訂的 SecretsTokenCache(實作 SDK 的 TokenCache 介面)會將這些權杖持久化到 secrets.json,以便它們在 CLI 調用之間持續存在。

驗證解析順序:CAIDO_PAT 環境變數 → ~/.agents/config/secrets.json 中的 PAT → 有效的快取存取權杖 → 錯誤並顯示設定說明

CLI 工具

位於 ~/.agents/skills/caido-mode/caido-client.ts。所有命令都輸出 JSON。


HTTP 歷史記錄與測試命令

search - 使用 HTTPQL 搜尋 HTTP 歷史記錄

npx tsx caido-client.ts search 'req.method.eq:"POST" AND resp.code.eq:200'
npx tsx caido-client.ts search 'req.host.cont:"api"' --limit 50
npx tsx caido-client.ts search 'req.host.cont:"api"' --desc --limit 10
npx tsx caido-client.ts search 'req.path.cont:"/admin"' --ids-only
npx tsx caido-client.ts search 'resp.raw.cont:"password"' --after <cursor>

recent - 取得最近的請求

npx tsx caido-client.ts recent
npx tsx caido-client.ts recent --limit 50

get / get-response - 檢索完整詳細資訊

npx tsx caido-client.ts get <request-id>
npx tsx caido-client.ts get <request-id> --headers-only
npx tsx caido-client.ts get-response <request-id>
npx tsx caido-client.ts get-response <request-id> --compact

edit - 編輯並重放(關鍵功能)

修改現有請求,同時保留所有 Cookie/驗證標頭:

# 變更路徑(IDOR 測試)
npx tsx caido-client.ts edit <id> --path /api/user/999

# 變更方法並新增主體
npx tsx caido-client.ts edit <id> --method POST --body '{"admin":true}'

# 新增/移除標頭
npx tsx caido-client.ts edit <id> --set-header "X-Forwarded-For: 127.0.0.1"
npx tsx caido-client.ts edit <id> --remove-header "X-CSRF-Token"

# 在請求中的任何位置尋找/取代文字
npx tsx caido-client.ts edit <id> --replace "user123:::user456"

# 組合多個編輯
npx tsx caido-client.ts edit <id> --method PUT --path /api/admin --body '{"role":"admin"}' --compact

# 為重複探測重用現有的重放標籤頁/會話
npx tsx caido-client.ts edit <id> --path /api/user/1001 --session <session-id> --compact
選項說明
--method <METHOD>變更 HTTP 方法
--path <path>變更請求路徑
--set-header <Name: Value>新增或取代標頭(可重複)
--remove-header <Name>移除標頭(可重複)
--body <content>設定請求主體(自動更新 Content-Length)
--replace <from>:::<to>在請求中的任何位置尋找/取代文字(可重複)
--session <id>重用現有重放會話而非建立新標籤頁
--collection <id>將新建立的重放會話放入集合
--sni <host>覆蓋 TLS SNI
--connect-host <host>在保留 HTTP 請求的同時連接到不同的主機
--connect-port <port>連接到不同的埠
--connect-tls / --connect-no-tls為連線強制使用 TLS/明文

replay / send-raw - 發送請求

# 按原樣重放
npx tsx caido-client.ts replay <request-id>

# 使用自訂原始資料重放
npx tsx caido-client.ts replay <id> --raw "GET /modified HTTP/1.1\r\nHost: example.com\r\n\r\n"

# 發送完全自訂的請求
npx tsx caido-client.ts send-raw --host example.com --port 443 --tls --raw "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n"
npx tsx caido-client.ts send-raw --host example.com --raw @request.txt --name "G /"
cat request.txt | npx tsx caido-client.ts send-raw --host example.com --raw -

# 在保留所需請求 Host/SNI 的同時連接到別處
npx tsx caido-client.ts replay <id> --connect-host 10.0.0.5 --connect-port 8443 --sni example.com

--raw 接受帶有 \r\n 跳脫序列的字串、@file 從磁碟讀取、或 - 從標準輸入讀取。

export-curl - 轉換為 curl 以用於 PoC

npx tsx caido-client.ts export-curl <request-id>

輸出一個包含所有標頭和主體的、立即可用的 curl 命令。


重放標籤頁查詢

當 Caido 重放標籤頁已開啟,並且您想要直接從其活動條目開始工作時使用這些命令。

npx tsx caido-client.ts get-session <session-id-or-name> --compact
npx tsx caido-client.ts replay-entries <session-id-or-name> --limit 20
npx tsx caido-client.ts replay-entries <session-id-or-name> --raw --compact
npx tsx caido-client.ts edit-session <session-id-or-name> --body '{"test":true}' --compact

sessions-entries 可作為 replay-entries 的別名使用。


重放會話與集合

會話

# 從現有請求建立重放會話
npx tsx caido-client.ts create-session <request-id>
npx tsx caido-client.ts create-session <request-id> --collection <collection-id>

# 始終為會話重新命名,以便在 Caido UI 中輕鬆識別
npx tsx caido-client.ts rename-session <session-id> "idor-user-profile"

# 列出所有重放會話
npx tsx caido-client.ts replay-sessions
npx tsx caido-client.ts replay-sessions --limit 50

# 在集合之間移動會話
npx tsx caido-client.ts move-session <session-id> <collection-id>

# 刪除重放會話
npx tsx caido-client.ts delete-sessions <session-id-1>,<session-id-2>

集合

將重放會話組織到集合中:

# 列出重放集合
npx tsx caido-client.ts replay-collections
npx tsx caido-client.ts replay-collections --limit 50

# 建立集合
npx tsx caido-client.ts create-collection "IDOR Testing"

# 重新命名集合
npx tsx caido-client.ts rename-collection <collection-id> "Auth Bypass Tests"

# 刪除集合
npx tsx caido-client.ts delete-collection <collection-id>

模糊測試

# 建立用於模糊測試的自動化會話
npx tsx caido-client.ts create-automate-session <request-id>

# 開始模糊測試(先在 Caido UI 中配置有效負載和標記)
npx tsx caido-client.ts fuzz <session-id>

範圍管理

定義您的測試範圍。使用 glob 模式。

# 列出所有範圍
npx tsx caido-client.ts scopes

# 建立具有允許清單和拒絕清單的範圍
npx tsx caido-client.ts create-scope "Target Corp" --allow "*.target.com,*.target.io" --deny "*.cdn.target.com"

# 更新範圍
npx tsx caido-client.ts update-scope <scope-id> --allow "*.target.com,*.api.target.com"

# 刪除範圍
npx tsx caido-client.ts delete-scope <scope-id>

Glob 模式: *.example.com 匹配 example.com 的任何子域。


篩選器預設

將常用的 HTTPQL 查詢儲存為具名預設。

# 列出已儲存的篩選器
npx tsx caido-client.ts filters

# 建立篩選器預設
npx tsx caido-client.ts create-filter "API Errors" --query 'req.path.cont:"/api/" AND resp.code.gte:400'
npx tsx caido-client.ts create-filter "Auth Endpoints" --query 'req.path.regex:"/(login|auth|oauth)/"' --alias "auth"

# 更新篩選器
npx tsx caido-client.ts update-filter <filter-id> --query 'req.path.cont:"/api/" AND resp.code.gte:500'

# 刪除篩選器
npx tsx caido-client.ts delete-filter <filter-id>

環境變數

儲存在會話之間持續存在的測試變數。非常適合使用多個使用者 ID 進行 IDOR 測試。

# 列出環境
npx tsx caido-client.ts envs

# 建立環境
npx tsx caido-client.ts create-env "IDOR-Test"

# 設定變數
npx tsx caido-client.ts env-set <env-id> victim_user_id "user_456"
npx tsx caido-client.ts env-set <env-id> attacker_token "eyJhbG..."

# 選擇活躍環境
npx tsx caido-client.ts select-env <env-id>

# 取消選擇環境
npx tsx caido-client.ts select-env

# 刪除環境
npx tsx caido-client.ts delete-env <env-id>

發現項目

建立、列出和更新安全發現。會顯示在 Caido 的「發現」標籤頁中。

# 列出所有發現
npx tsx caido-client.ts findings
npx tsx caido-client.ts findings --limit 50

# 取得特定發現
npx tsx caido-client.ts get-finding <finding-id>

# 建立連結到請求的發現
npx tsx caido-client.ts create-finding <request-id> \
  --title "IDOR in user profile endpoint" \
  --description "Can access other users' profiles by changing ID parameter" \
  --reporter "rez0"

# 使用重複資料刪除金鑰(防止重複)
npx tsx caido-client.ts create-finding <request-id> \
  --title "Auth bypass on /admin" \
  --dedupe-key "admin-auth-bypass"

# 更新發現
npx tsx caido-client.ts update-finding <finding-id> \
  --title "Updated title" \
  --description "Updated description"

任務

監控和取消背景任務(匯入、匯出等)。

# 列出所有任務
npx tsx caido-client.ts tasks

# 取消正在執行的任務
npx tsx caido-client.ts cancel-task <task-id>

專案管理

# 列出所有專案
npx tsx caido-client.ts projects

# 切換活躍專案
npx tsx caido-client.ts select-project <project-id>

託管檔案

# 列出託管檔案
npx tsx caido-client.ts hosted-files

# 刪除託管檔案
npx tsx caido-client.ts delete-hosted-file <file-id>

攔截控制

# 檢查攔截狀態
npx tsx caido-client.ts intercept-status

# 啟用/停用攔截
npx tsx caido-client.ts intercept-enable
npx tsx caido-client.ts intercept-disable

資訊、健康狀態與外掛程式

# 目前使用者資訊
npx tsx caido-client.ts viewer

# 列出已安裝的外掛程式
npx tsx caido-client.ts plugins

# 檢查 Caido 實例健康狀態(版本、就緒狀態)
npx tsx caido-client.ts health

輸出控制

適用於 get、get-response、replay、edit、send-raw:

旗標說明
--max-body <n>最大響應主體行數(預設:200,0=無限制)
--max-body-chars <n>最大主體字元數(預設:5000,0=無限制)
--no-request在輸出中跳過請求原始資料
--headers-only僅 HTTP 標頭,不包含主體
--compact快捷方式:--no-request --max-body 50 --max-body-chars 5000

HTTPQL 參考

Caido 用於搜尋 HTTP 歷史記錄的查詢語言。

關鍵:字串值必須用引號括起來。整數值不要用引號。

關鍵:HTTPQL 沒有 NOT 運算子。永遠不要寫 NOT expr。請改用否定運算子變體:

  • ncont (not contains), nlike (not like), nregex (not regex), ne (not equals)
  • 錯誤: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往返時間 (ms)
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, 括號用於分組

範例查詢

# 狀態碼為 200 的 POST 請求
req.method.eq:"POST" AND resp.code.eq:200

# API 請求
req.host.cont:"api" OR req.path.cont:"/"

進階查詢範例

# API 回應中的錯誤(狀態碼 >= 400)
req.path.cont:"/api/" AND resp.code.gte:400

# 包含敏感內容的回應
resp.raw.cont:"password" OR resp.raw.cont:"secret" OR resp.raw.cont:"token"

# 特定時間範圍
req.created_at.gte:"2024-01-01" AND req.created_at.lt:"2024-02-01"

# 對應端點進行模糊測試的特定來源
source.eq:"automate" AND req.path.cont:"/api/"

# 帶有特定查詢字串的請求
req.query.cont:"debug=true"

# 從特定主機排除圖像請求
req.host.cont:"target.com" AND req.ext.ne:".jpg" AND req.ext.ne:".png"

# 來自重放且狀態碼非 200 的請求
source.eq:"replay" AND resp.code.ne:200

命令列使用

所有查詢都在命令列上以單個參數形式傳遞(如有需要請使用引號):

npx tsx caido-client.ts search 'req.host.cont:"target.com" AND resp.code.gte:400'
npx tsx caido-client.ts search 'req.path.regex:"/admin.*" AND source.eq:"replay"'
npx tsx caido-client.ts search 'req.raw.cont:"Authorization"' --limit 100

故障排除

驗證錯誤

如果看到錯誤:

  1. 檢查您的 PAT 是否有效:

    npx tsx ~/.agents/skills/caido-mode/caido-client.ts auth-status
    
  2. 使用新權杖重新執行設定:

    npx tsx ~/.agents/skills/caido-mode/caido-client.ts setup <new-pat>
    
  3. 或設定環境變數(優先於儲存的權杖):

    export CAIDO_PAT=caido_xxxxx
    

連線問題

如果 Caido 無法在預設位置使用:

# 檢查 Caido 是否正在執行
npx tsx ~/.agents/skills/caido-mode/caido-client.ts health

# 使用非預設 URL 重新設定
npx tsx ~/.agents/skills/caido-mode/caido-client.ts setup <pat> http://192.168.1.100:8080

CLI 路徑

確保使用正確的路徑。該技能安裝在 ~/.agents/skills/caido-mode/ 中:

# 從任何目錄執行
npx tsx ~/.agents/skills/caido-mode/caido-client.ts <command>

# 或從技能目錄內執行
cd ~/.agents/skills/caido-mode
npx tsx caido-client.ts <command>

請款 RAM / 回應大小

較大的響應會被截斷為預設限制。使用輸出控制旗標進行調整:

# 查看完整的響應主體
npx tsx caido-client.ts get <id> --max-body 0 --max-body-chars 0

有用提示

高效 IDOR 測試

  1. 在 HTTP 歷史記錄中找到一個具有有效驗證的請求(例如 GET /api/user/123)
  2. 使用 edit 變更路徑:
    npx tsx caido-client.ts edit <id> --path /api/user/999 --compact
    
  3. 對不同的使用者 ID 重複步驟 2
  4. 所有請求都在 Caido UI 中可見,以便進行後續分析

使用環境變數

# 為 IDOR 測試設定環境
npx tsx caido-client.ts create-env "IDOR Targets"
npx tsx caido-client.ts env-set <env-id> victim_ids "user_456,user_789,user_101"
npx tsx caido-client.ts select-env <env-id>

記錄您的發現

當您找到安全問題時,立即記錄:

npx tsx caido-client.ts create-finding <request-id> \
  --title "IDOR: Accessed other user's profile" \
  --description "Was able to view profile of user_456 by changing ID from 123 to 456" \
  --reporter "ai-agent" \
  --dedupe-key "idor-user-profile-456"

有關更多資訊,請參閱 Caido 文件。

相關技能