文章总结: 本文详细介绍了如何通过补丁方式为智谱ZCode的browser-use插件扩展CDP调试API支持,使模型能够进行断点调试。作者分析了出厂版本缺少cdp分支的底层原因,并提供了修改执行桥、schema、Broker及模型侧脚本的完整步骤与替换清单。该方案可操作性强,为AI安全研究和浏览器自动化调试提供了实用参考。 综合评分: 85 文章分类: AI安全,漏洞分析,实战经验,安全工具
【AI安全】智谱ZCode补丁扩展CDP调试API支持模型自动断点调试
原创
挖个洞先 挖个洞先
挖个洞先
2026年8月9日 00:38 北京
在小说阅读器读本章
去阅读
“ 当日嫌它的唱法做作,现在听起来竟然很生动,可能是时光让耳朵变得宽容。——《幻听》 ”
01
—
操作步骤
1、输入提示词,可以看到Zcode无法调用断点调试相关api
https://cdn-zcode.z.ai/zcode/electron/releases/3.7.3/windows-x64/ZCode-3.7.3-win-x64.exe
访问 baidu.com,然后 evaluate("1+1")、enableDebugger、events、openDevTools
2、查看调用轨迹日志,调用browser-use skill
C:\Users\Administrator\.zcode\cli\rollout\
3、查看运行日志里的 tool 顺序
C:\Users\Administrator\.zcode\cli\logSkill → mcp__node_repl__js(setupBrowserRuntime)→ mcp__node_repl__js(getForUrl+documentation)→ mcp__node_repl__js(tabs.new+goto)→ mcp__node_repl__js(playwright.evaluate)
4、查看browser-use提供的API,没有断点调试相关接口
C:\Users\Administrator\.zcode\cli\plugins\cache\zcode-plugins-official\browser-use\0.2.1\docs\api.json
5、主机日志确认IAB已经attach CDP,只是没有提供API调用
C:\Users\Administrator\.zcode\v2\logs\
6、模型如何驱动浏览器
C:\Users\Administrator\.zcode\cli\plugins\cache\zcode-plugins-official\browser-use\0.2.1\scripts\browser-client.mjs
模型 → 工具 mcp__node_repl__js → 执行 JS:import browser-client,使用 agent.browsers 与 tab 上的方法 → 客户端把操作收成 command 对象,经 transport.execute(browserId, generation, command) 发出 → Node REPL 浏览器 Broker(命名管道或 socket,zcode.cjs 侧)收到请求 → Broker 调用 browserControlPort.execute,把 command 交给桌面浏览器控制口 → Host 进程 IPC:interaction/browserExecute → Main 进程:校验消息后执行 runBrowserCommandOnView,再进入 BrowserUse.execute(command) → Main 根据 command.method 选择分支处理 (出厂已有例如 navigate、playwright、getState、screenshot、close; 没有 cdp 分支,所以 enableDebugger 一类调不到)「command.method 分支」说明:command 是一个 JSON 对象,里面有字段 method。Main 里类似 if (method === "navigate") 做导航,if (method === "playwright") 做 Playwright 动作。出厂枚举到 list 为止,没有 method === "cdp",模型再怎么调断点相关名字也不会进调试分支。
7、出厂执行桥:没有 method=cdp
C:\Users\Administrator\.zcode\report\local-backups-373\app.asar.bak-unpacked\out\main\index.js
8、补丁执行桥:增加 method=cdp
C:\Users\Administrator\.zcode\report\files\asar-extracted\out\main\index.js
9、出厂 Main schema
C:\Users\Administrator\.zcode\report\local-backups-373\app.asar.bak-unpacked\out\main\chunk-PWHDRJIQ.js
10、补丁 Main schema:加上 cdp
C:\Users\Administrator\.zcode\report\files\asar-extracted\out\main\chunk-PWHDRJIQ.js
11、补丁 Host schema:加上 cdp
C:\Users\Administrator\.zcode\report\files\asar-extracted\out\host\chunk-VMEOUWWD.js
12、补丁 Broker:g.enum 加 cdp
C:\Users\Administrator\.zcode\report\files\glm\zcode.cjs
13、补丁 Broker:parse 前先取请求 raw.id,避免错误回包 id 错乱
C:\Users\Administrator\.zcode\report\files\glm\zcode.cjs
14、补丁模型侧:模型侧暴露 tab.cdp 入口
C:\Users\Administrator\.zcode\report\files\plugin\scripts\browser-client.mjs
15、补丁文档:api.json 声明 enableDebugger
C:\Users\Administrator\.zcode\report\files\plugin\docs\api.json
16、效果如下
打开 https://www.baidu.com。用 tab.cdp.evaluate("1+1")、tab.cdp.enableDebugger()、tab.cdp.events({limit:50})、tab.openDevTools() 依次调用。然后控制台执行(function() { var stringify = JSON.stringify; JSON.stringify = function(params) { console.log("Hook JSON.stringify ——> ", params); debugger; return stringify(params); }})();
17、替换清单
关闭进程Get-Process -Name ZCode -ErrorAction SilentlyContinue | Stop-Process -Force
https://github.com/Almost-Zhangsan/zcode-cdp-patch-3.7.3/blob/main/files/glm/zcode.cjs.gz(下载后解压为 zcode.cjs,见同目录 README)→ D:\ZCode\resources\glm\zcode.cjs
https://github.com/Almost-Zhangsan/zcode-cdp-patch-3.7.3/blob/main/files/plugin/scripts/browser-client.mjs→ C:\Users\Administrator\.zcode\cli\plugins\cache\zcode-plugins-official\browser-use\0.2.1\scripts\browser-client.mjs→ D:\ZCode\resources\glm\packages\browser-use-plugin\scripts\browser-client.mjs
https://github.com/Almost-Zhangsan/zcode-cdp-patch-3.7.3/blob/main/files/plugin/docs/api.json→ C:\Users\Administrator\.zcode\cli\plugins\cache\zcode-plugins-official\browser-use\0.2.1\docs\api.json→ D:\ZCode\resources\glm\packages\browser-use-plugin\docs\api.json
https://github.com/Almost-Zhangsan/zcode-cdp-patch-3.7.3/tree/main/files/asar-patches(解包本机官方 app.asar 后覆盖下列 3 个文件,再 asar pack) out/main/index.js out/main/chunk-PWHDRJIQ.js out/host/chunk-VMEOUWWD.js→ 打包结果覆盖 D:\ZCode\resources\app.asar
raw(可直接下载):https://raw.githubusercontent.com/Almost-Zhangsan/zcode-cdp-patch-3.7.3/main/files/plugin/scripts/browser-client.mjshttps://raw.githubusercontent.com/Almost-Zhangsan/zcode-cdp-patch-3.7.3/main/files/plugin/docs/api.jsonhttps://raw.githubusercontent.com/Almost-Zhangsan/zcode-cdp-patch-3.7.3/main/files/glm/zcode.cjs.gz
打包 asar 步骤见仓库 README:https://github.com/Almost-Zhangsan/zcode-cdp-patch-3.7.3
免责声明:
本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。
任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。
本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我。
本文转载自:挖个洞先 挖个洞先 挖个洞先《【AI安全】智谱ZCode补丁扩展CDP调试API支持模型自动断点调试》
版权声明
本站仅做备份收录,仅供研究与教学参考之用。
读者将信息用于其他用途的,全部法律及连带责任由读者自行承担,本站不承担任何责任。








![[NewStarCTF2023公开赛道]游戏高手](/images/random/titlepic/11.jpg)


评论