鱼眼 發表於 2026-4-9 19:38:00

教程:用 VS Code 与 GitHub Copilot 结合 Jadx-MCP 打造超强 Android AI 逆向工作流

<p>传统 Android 逆向分析常常需要在 Jadx (反编译工具) 和各种笔记/编辑器之间来回切换。随着大模型和 MCP(Model Context Protocol,模型上下文协议)的普及,我们现在可以直接在&nbsp;<strong>VS Code</strong>&nbsp;中,通过自然语言让&nbsp;<strong>GitHub Copilot</strong>&nbsp;远程调用 Jadx 来帮我们反编译、搜索代码、甚至直接分析出加密算法和 Flag!</p>
<p>这篇博客将手把手教你如何搭建这套工作流。</p>
<h2 id="一前期准备下载并运行-jadx-mcp-插件">一、前期准备:下载并运行 Jadx-MCP 插件</h2>
<p><code>jadx-mcp</code>&nbsp;是一个桥接服务,它通过在本地启动一个 Python 或 Java 服务器,将 Jadx 的 API(例如获取 Class 源码、搜索关键词、获取 AndroidManifest)暴露给外部大模型客户端(如 VS Code 中的 Copilot 或 Cline)。</p>
<h3 id="1-软件环境">1. 软件环境</h3>
<ul>
<li><strong>安装 Java (JDK 11+)</strong>:用于运行 Jadx 本体。</li>
<li><strong>安装 Python (3.10+)</strong>:MCP 桥接服务通常基于 Python (FastMCP) 构建。</li>
<li><strong>下载 Jadx-MCP 服务包</strong>:获取对应的&nbsp;<code>jadx-mcp-server-vX.X.X.zip</code>&nbsp;以及 Jadx 本体(部分封装版直接将它作为 Jadx 插件发布,如&nbsp;<code>jadx-ai-mcp-x.x.x.jar</code>)。</li>
</ul>
<h3 id="2-初始化核心依赖-python端">2. 初始化核心依赖 (Python端)</h3>
<p>如果你拿到的&nbsp;<code>jadx-mcp</code>&nbsp;是一个带有&nbsp;<code>jadx_mcp_server.py</code>&nbsp;的解压包,你需要先在终端为其安装环境依赖。</p>
<p>打开命令行(以刚才的解压目录为例):</p>
<pre><code># 激活你的 Python 环境 (如果你有虚拟环境)

# 必须安装 fastmcp 及其网络依赖包

pip install pydantic fastapi httpx "fastmcp&gt;=3.0.2" -U
</code></pre>
<blockquote>
<p><strong>排坑避坑</strong>:如果你使用的是&nbsp;<code>java -jar jadx-ai-mcp.jar</code>&nbsp;遇到&nbsp;<code>no main manifest attribute</code>&nbsp;闪退报错,请务必确认该 jar 文件只是个由 Jadx GUI 挂载的插件(默认在 8650 端口通信)。<strong>你实际需要让 Copilot 运行的是那个&nbsp;<code>.py</code>&nbsp;的桥接服务端脚本。</strong></p>
</blockquote>
<h2 id="二配置-vs-code将-jadx-注册进-copilot-大脑">二、配置 VS Code:将 Jadx 注册进 Copilot 大脑</h2>
<p>GitHub Copilot 及同类 AI 插件(如 Claude Dev/Roo Code)都是通过读取 VS Code 的全局&nbsp;mcp.json&nbsp;配置文件来加载外部工具的。我们需要将 Jadx 服务手动注入其中。</p>
<h3 id="1-修改全局-mcp-配置文件">1. 修改全局 MCP 配置文件</h3>
<p>找到并打开你的 VS Code&nbsp;mcp.json&nbsp;文件。</p>
<ul>
<li><strong>Windows 路径</strong>:<code>C:\Users\&lt;你的用户名&gt;\AppData\Roaming\Code\User\mcp.json</code></li>
<li><strong>macOS 路径</strong>:<code>~/Library/Application Support/Code/User/mcp.json</code></li>
</ul>
<p><em>(如果该文件不存在,新建一个即可)</em></p>
<h3 id="2-注入-jadx-mcp-节点配置">2. 注入 jadx-mcp 节点配置</h3>
<p>在&nbsp;<code>"servers"</code>&nbsp;JSON 对象中,新增&nbsp;<code>jadx-mcp</code>&nbsp;的配置。以下是经过实测的完美跑通配置(请注意<strong>将路径替换为你本地真实的 Python 路径和服务脚本路径</strong>):</p>
<pre><code>{

&nbsp; "servers": {

&nbsp; &nbsp; "jadx-mcp": {

&nbsp; &nbsp; &nbsp; "isActive": true,

&nbsp; &nbsp; &nbsp; "command": "D:\\Programs\\Python\\Python310\\python.exe",

&nbsp; &nbsp; &nbsp; "args": [

&nbsp; &nbsp; &nbsp; &nbsp; "D:\\Programs\\Android Reverse\\jadx-mcp\\jadx-mcp-server-v6.2.0\\jadx-mcp-server\\jadx_mcp_server.py"

&nbsp; &nbsp; &nbsp; ],

&nbsp; &nbsp; &nbsp; "timeout": 1800,

&nbsp; &nbsp; &nbsp; "disabled": false,

&nbsp; &nbsp; &nbsp; "autoApprove": [

&nbsp; &nbsp; &nbsp; &nbsp; "fetch_current_class",

&nbsp; &nbsp; &nbsp; &nbsp; "get_selected_text",

&nbsp; &nbsp; &nbsp; &nbsp; "get_method_by_name",

&nbsp; &nbsp; &nbsp; &nbsp; "get_all_classes",

&nbsp; &nbsp; &nbsp; &nbsp; "get_class_source",

&nbsp; &nbsp; &nbsp; &nbsp; "search_method_by_name",

&nbsp; &nbsp; &nbsp; &nbsp; "get_methods_of_class",

&nbsp; &nbsp; &nbsp; &nbsp; "search_classes_by_keyword",

&nbsp; &nbsp; &nbsp; &nbsp; "get_fields_of_class",

&nbsp; &nbsp; &nbsp; &nbsp; "get_smali_of_class",

&nbsp; &nbsp; &nbsp; &nbsp; "get_manifest_component",

&nbsp; &nbsp; &nbsp; &nbsp; "get_android_manifest",

&nbsp; &nbsp; &nbsp; &nbsp; "get_strings",

&nbsp; &nbsp; &nbsp; &nbsp; "get_all_resource_file_names",

&nbsp; &nbsp; &nbsp; &nbsp; "get_resource_file",

&nbsp; &nbsp; &nbsp; &nbsp; "get_main_application_classes_names",

&nbsp; &nbsp; &nbsp; &nbsp; "get_main_application_classes_code",

&nbsp; &nbsp; &nbsp; &nbsp; "get_main_activity_class",

&nbsp; &nbsp; &nbsp; &nbsp; "get_xrefs_to_class",

&nbsp; &nbsp; &nbsp; &nbsp; "get_xrefs_to_method",

&nbsp; &nbsp; &nbsp; &nbsp; "get_xrefs_to_field"

&nbsp; &nbsp; &nbsp; ],

&nbsp; &nbsp; &nbsp; "alwaysAllow": [

&nbsp; &nbsp; &nbsp; &nbsp; "fetch_current_class",

&nbsp; &nbsp; &nbsp; &nbsp; "get_selected_text",

&nbsp; &nbsp; &nbsp; &nbsp; "get_method_by_name",

&nbsp; &nbsp; &nbsp; &nbsp; "get_all_classes",

&nbsp; &nbsp; &nbsp; &nbsp; "get_class_source",

&nbsp; &nbsp; &nbsp; &nbsp; "search_method_by_name",

&nbsp; &nbsp; &nbsp; &nbsp; "get_methods_of_class",

&nbsp; &nbsp; &nbsp; &nbsp; "search_classes_by_keyword",

&nbsp; &nbsp; &nbsp; &nbsp; "get_fields_of_class",

&nbsp; &nbsp; &nbsp; &nbsp; "get_smali_of_class",

&nbsp; &nbsp; &nbsp; &nbsp; "get_manifest_component",

&nbsp; &nbsp; &nbsp; &nbsp; "get_android_manifest",

&nbsp; &nbsp; &nbsp; &nbsp; "get_strings",

&nbsp; &nbsp; &nbsp; &nbsp; "get_all_resource_file_names",

&nbsp; &nbsp; &nbsp; &nbsp; "get_resource_file",

&nbsp; &nbsp; &nbsp; &nbsp; "get_main_application_classes_names",

&nbsp; &nbsp; &nbsp; &nbsp; "get_main_application_classes_code",

&nbsp; &nbsp; &nbsp; &nbsp; "get_main_activity_class",

&nbsp; &nbsp; &nbsp; &nbsp; "get_xrefs_to_class",

&nbsp; &nbsp; &nbsp; &nbsp; "get_xrefs_to_method",

&nbsp; &nbsp; &nbsp; &nbsp; "get_xrefs_to_field"

&nbsp; &nbsp; &nbsp; ],

&nbsp; &nbsp; &nbsp; "name": "jadx-mcp"

&nbsp; &nbsp; }

&nbsp; }

}
</code></pre>
<blockquote>
<p><em><strong>设定说明</strong></em>:<code>autoApprove</code>&nbsp;/&nbsp;<code>alwaysAllow</code>&nbsp;列表里的工具名(如&nbsp;<code>get_class_source</code>&nbsp;等)意味着 Copilot 在调用 Jadx 拉取代码时,不需要每次都弹窗要求你手动点击“Allow”。这是实现自动化行云流水体验的关键。</p>
</blockquote>
<h3 id="3-重启-vs-code-生效">3. 重启 VS Code 生效</h3>
<p>配置写完毕后,必须要<strong>重启 VS Code</strong>。<br>
可以直接使用快捷键&nbsp;<code>Ctrl+Shift+P</code>&nbsp;-&gt; 输入&nbsp;<code>Reload Window</code>&nbsp;(重新加载窗口)。</p>
<hr>
<h2 id="三神力初现实战应用体验">三、神力初现:实战应用体验</h2>
<p>配置完成后,Jadx 强大的逆向功能就已经内化进 Copilot 里了。</p>
<h3 id="工作流协同演示">工作流协同演示:</h3>
<ol>
<li><strong>获取应用样本</strong>:从雷电模拟器或手机中提取出待分析的 APK 文件,用运行着 MCP 插件的 Jadx-GUI 将其打开。</li>
<li><strong>呼唤 AI</strong>:在 VS Code 打开 Copilot Chat,你可以像跟专业逆向工程师对话一样发送指令了。</li>
</ol>
<p>转载请注明来源&nbsp;Joyooosama - 博客园!</p><br><br>
来源:https://www.cnblogs.com/Joyooo/p/19842866
頁: [1]
查看完整版本: 教程:用 VS Code 与 GitHub Copilot 结合 Jadx-MCP 打造超强 Android AI 逆向工作流