zhizhuodemao/js-reverse-mcp

GitHub: zhizhuodemao/js-reverse-mcp

一个专为 AI 编程助手设计的 JS 逆向调试服务器,具备多层反检测能力,支持断点调试、函数 Hook、网络分析等功能,让 AI 能够直接参与网页 JavaScript 的逆向分析工作。

Stars: 301 | Forks: 54

# JS Reverse MCP English | [中文](README_zh.md) 一个 JavaScript 逆向工程 MCP 服务器,使 AI 编程助手(Claude, Cursor, Copilot)能够调试和分析网页中的 JavaScript 代码。 基于 [Patchright](https://github.com/nicecaesar/patchright) 反检测引擎构建,具备多层反 Bot 绕过能力,使其能够在具有 Bot 检测的网站(如知乎和 Google)上工作。 ## 功能特性 - **反检测浏览器**:基于 Patchright(Playwright 反检测分支),60+ 隐蔽启动参数,绕过主流反 Bot 系统 - **脚本分析**:列出所有已加载的 JS 脚本,搜索代码,获取源代码 - **断点调试**:设置/移除断点,条件断点,在压缩代码中精确定位 - **函数追踪**:Hook 任意函数(包括模块内部函数),监控调用和返回值 - **执行控制**:暂停/恢复执行,单步调试(单步跳过/进入/退出) - **运行时检查**:在断点处求值表达式,检查作用域变量 - **网络分析**:查看请求发起者调用栈,设置 XHR 断点,WebSocket 消息分析 - **事件监控**:监控 DOM 事件,检查存储数据 ## 环境要求 - [Node.js](https://nodejs.org/) v20.19 或更高版本 - [Chrome](https://www.google.com/chrome/) 稳定版 ## 快速开始 无需安装。添加到您的 MCP 客户端配置中: ``` { "mcpServers": { "js-reverse": { "command": "npx", "args": ["js-reverse-mcp"] } } } ``` ### Claude Code ``` claude mcp add js-reverse npx js-reverse-mcp ``` ### Cursor 进入 `Cursor Settings` -> `MCP` -> `New MCP Server`,并使用上述配置。 ### VS Code Copilot ``` code --add-mcp '{"name":"js-reverse","command":"npx","args":["js-reverse-mcp"]}' ``` ## 本地安装(备选方案) ``` git clone https://github.com/nicecaesar/js-reverse-mcp.git cd js-reverse-mcp npm install npm run build ``` 然后在您的 MCP 配置中使用本地路径: ``` { "mcpServers": { "js-reverse": { "command": "node", "args": ["/path/to/js-reverse-mcp/build/src/index.js"] } } } ``` ## 反检测 js-reverse-mcp 包含多层反检测措施,以便在具有 Bot 检测的网站上工作: ### 反检测架构 | 层级 | 描述 | |-------|-------------| | Patchright 引擎 | C++ 级别的反检测补丁,移除 `navigator.webdriver`,避免 `Runtime.enable` 泄露 | | 60+ 隐蔽参数 | 移除自动化特征,绕过 headless 检测,GPU/网络/行为指纹欺骗 | | 有害参数移除 | 排除 `--enable-automation` 及其他 4 个默认 Playwright 参数 | | 静默 CDP 导航 | 导航工具不激活 CDP 域,仅通过 Playwright 级别的监听器捕获请求,防止反 Bot 脚本检测调试协议活动 | | Google Referer 欺骗 | 所有导航自动包含 `referer: https://www.google.com/` | | 持久化登录状态 | 默认使用持久化 user-data-dir,跨会话保留登录状态 | ## 工具 ### 脚本分析 | 工具 | 描述 | | ------------------- | -------------------------------------------------------------- | | `list_scripts` | 列出页面中加载的所有 JavaScript 脚本 | | `get_script_source` | 获取脚本源代码,支持行范围或字符偏移(用于压缩文件) | | `search_in_sources` | 在所有脚本中搜索字符串或正则表达式模式 | ### 断点管理 | 工具 | 描述 | | ------------------------ | ---------------------------------------------------------- | | `set_breakpoint_on_text` | 通过搜索代码文本设置断点(适用于压缩代码) | | `remove_breakpoint` | 移除断点 | | `list_breakpoints` | 列出所有活动断点 | ### 调试控制 | 工具 | 描述 | | ----------------------- | --------------------------------------------- | | `get_paused_info` | 获取暂停状态、调用栈和作用域变量 | | `resume` | 恢复执行 | | `pause` | 暂停执行 | | `step_over` | 单步跳过 | | `step_into` | 单步进入 | | `step_out` | 单步退出 | ### 函数 Hook | 工具 | 描述 | | ----------------- | --------------------------------------------------------------------- | | `hook_function` | Hook 全局函数或对象方法,记录调用和返回值 | | `unhook_function` | 移除函数 Hook | | `list_hooks` | 列出所有活动 Hook | | `trace_function` | 追踪任意函数调用(包括模块内部函数),使用条件断点 | ### 网络调试 | 工具 | 描述 | | ------------------------------- | ----------------------------------------- | | `list_network_requests` | 列出网络请求 | | `get_network_request` | 获取请求详情和响应内容 | | `get_request_initiator` | 获取网络请求的 JavaScript 调用栈 | | `break_on_xhr` | 设置 XHR/Fetch 断点 | | `remove_xhr_breakpoint` | 移除 XHR 断点 | | `list_websocket_connections` | 列出 WebSocket 连接 | | `get_websocket_messages` | 获取 WebSocket 消息 | | `analyze_websocket_messages` | 分析 WebSocket 消息模式 | ### 检查工具 | 工具 | 描述 | | ----------------------- | ---------------------------------------------- | | `evaluate_script` | 在页面中执行 JavaScript | | `inspect_object` | 深度检查 JavaScript 对象结构 | | `get_storage` | 获取 cookies, localStorage, sessionStorage | | `monitor_events` | 监控元素或窗口上的 DOM 事件 | | `stop_monitor` | 停止事件监控 | | `list_console_messages` | 获取控制台消息 | | `get_console_message` | 获取控制台消息详情 | ### 页面管理 | 工具 | 描述 | | ----------------- | ------------------------------------- | | `list_pages` | 列出浏览器中打开的页面 | | `select_page` | 选择一个页面作为调试上下文 | | `new_page` | 创建新页面并导航到 URL | | `navigate_page` | 导航、后退、前进或重新加载 | | `list_frames` | 列出页面中的所有 frame | | `select_frame` | 选择一个 frame 作为执行上下文 | | `take_screenshot` | 截取页面截图 | ## 使用示例 ### 基本 JS 逆向工程流程 1. **打开目标页面** ``` Open https://example.com and list all loaded JS scripts ``` 2. **查找目标函数** ``` Search all scripts for code containing "encrypt" ``` 3. **设置断点** ``` Set a breakpoint at the entry of the encryption function ``` 4. **触发并分析** ``` Trigger an action on the page, then inspect arguments, call stack and scope variables when the breakpoint hits ``` ### Hook 加密函数 ``` Hook the fetch function to log all API call arguments and return values ``` ### 追踪模块内部函数 ``` Use trace_function to trace the webpack-bundled internal function "encryptData", view arguments of each call without setting breakpoints ``` ### WebSocket 协议分析 ``` List WebSocket connections, analyze message patterns, view messages of specific types ``` ## 配置选项 | 选项 | 描述 | 默认值 | | ---------------------- | ------------------------------------------ | ---------- | | `--browserUrl, -u` | 连接到运行中的 Chrome 实例 | - | | `--wsEndpoint, -w` | WebSocket 端点连接 | - | | `--headless` | 以 headless 模式运行 | false | | `--executablePath, -e` | 自定义 Chrome 可执行文件路径 | - | | `--isolated` | 使用临时用户数据目录(每次全新) | false | | `--channel` | Chrome 渠道: stable, canary, beta, dev | stable | | `--viewport` | 初始视口大小,例如 `1280x720` | 真实大小 | | `--hideCanvas` | 启用 Canvas 指纹噪声 | false | | `--blockWebrtc` | 阻止 WebRTC 以防止真实 IP 泄露 | false | | `--disableWebgl` | 禁用 WebGL 以防止 GPU 指纹识别 | false | | `--noStealth` | 禁用隐蔽启动参数(用于调试) | false | | `--proxyServer` | 代理服务器配置 | - | | `--logFile` | 调试日志文件路径 | - | ### 配置示例 **增强反检测(Canvas 噪声 + WebRTC 阻断):** ``` { "mcpServers": { "js-reverse": { "command": "npx", "args": [ "js-reverse-mcp", "--hideCanvas", "--blockWebrtc" ] } } } ``` **隔离模式(无持久化登录,每次全新配置):** ``` { "mcpServers": { "js-reverse": { "command": "npx", "args": [ "js-reverse-mcp", "--isolated" ] } } } ``` ### 连接到运行中的 Chrome 实例 1. 启动 Chrome(先关闭所有 Chrome 窗口,然后重启): **macOS** ``` /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debug ``` **Windows** ``` "C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="%TEMP%\chrome-debug" ``` 2. 配置 MCP 连接: ``` { "mcpServers": { "js-reverse": { "command": "npx", "args": [ "js-reverse-mcp", "--browser-url=http://127.0.0.1:9222" ] } } } ``` ## 故障排除 ### 被反 Bot 系统拦截 如果您在访问某些网站(例如知乎返回错误 40362)时被拦截: 1. **清除受污染的配置文件**:删除 `~/.cache/chrome-devtools-mcp/chrome-profile` 目录 2. **使用隔离模式**:添加 `--isolated` 标志 3. **启用 Canvas 噪声**:添加 `--hideCanvas` 标志 ## 安全提示 此工具将浏览器内容暴露给 MCP 客户端,允许检查、调试和修改浏览器中的任何数据。请勿在包含敏感信息的页面上使用。 ## 许可证 Apache-2.0
标签:BeEF, CDP协议, Chrome DevTools, Claude, Copilot, Cursor, CVE检测, GNU通用公共许可证, Go语言工具, JS逆向, MCP Server, MITM代理, Node.js, Patchright, Playwright, Web安全, 云资产清单, 代码分析, 凭证管理, 函数Hook, 反检测, 反爬虫绕过, 断点调试, 浏览器自动化, 爬虫, 特征检测, 网络安全, 自动化攻击, 蓝队分析, 逆向工程, 隐私保护