executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
re-browser-ext浏览器扩展逆向:权限清单、恶意行为定位、混淆还原、上架审查绕过面。 触发词:浏览器扩展、Chrome扩展、Firefox扩展、恶意扩展、extension。
Independent GitHub snapshot · Automated classification · Original documentation governs
unzip/7z 直接解包会报 extra bytes at beginning 警告但结果正确;python3 -m zipfile -e sample.crx ext/ 无警告apt install jq;macOS: brew install jq;Windows: 官方构建jq --versionapt install nodejs;macOS: brew install node;Windows: nodejs.org 官方安装包;验证: node --versionnpm install -g js-beautify,验证 js-beautify --version(压缩 JS 先格式化再读)chrome://extensions 开发者模式 → Load unpacked;Edge 同(edge://extensions)about:debugging#/runtime/this-firefox → Load Temporary Add-on(免签名临时加载)按顺序执行,每步产物存档(路径 + sha256,见 [[re-triage]])。
解包与结构:
unzip -o sample.crx -d ext/ 2>/dev/null || python3 -m zipfile -e sample.crx ext/
jq '.manifest_version, .name, .version' ext/manifest.json
jq '.permissions, .host_permissions' ext/manifest.json
# host_permissions 为 MV3 字段;MV2 站点权限在 permissions 内(含 URL 匹配模式)
manifest_version(2 还是 3)——MV2/MV3 的权限模型与能力差异决定后续所有判断(见 [[gotchas]])update_url(自托管更新清单,投毒面)、key(扩展 ID 派生)、externally_connectable(外部页面消息通道)、oauth2(令牌)、optional_permissions(运行时再要权)、minimum_chrome_version(兼容边界)_locales/(i18n 消息,可藏字符串)、icons/、options_page / options_ui、commands(快捷键,触发行为入口)、incognito(隐身窗口行为声明)权限审计(能力边界):
高危 API 权限:tabs(读标签页 URL/标题)、storage(数据收集缓存)、webRequest(流量观察;MV3 阻断能力仅企业策略部署例外,一般改走 declarativeNetRequest)、scripting(MV3 动态注入)、clipboardRead(剪贴板)、cookies(读站点 Cookie)、history、downloads、nativeMessaging(与宿主程序通信)、debugger
站点权限(host_permissions / MV2 permissions 内 URL 模式)决定能碰哪些网站的数据——<all_urls> 或 *://*/* 是高危信号
权限与声明用途对照:装了 storage+tabs+<all_urls> 但功能只是改主题——越权信号
权限风险速查(声明即能力,不必看代码):
| 权限 | 能力 | 恶意用途 |
|---|---|---|
tabs + <all_urls> | 读标签页 URL/标题 | 浏览习惯收集 |
storage | 本地持久化 | 收集数据缓存/配置下发 |
webRequest / declarativeNetRequest | 流量观察/规则修改 | 监控、注入、拦截 |
scripting / content_scripts | 页面注入 | 键盘记录、表单窃取 |
clipboardRead | 读剪贴板 | 剪贴板内容窃取(如钱包地址) |
cookies | 读/写站点 Cookie | 会话劫持 |
nativeMessaging | 与宿主程序通信 | 落地可执行/外带数据 |
downloads | 读写下载 | 下载投毒/篡改下载文件 |
恶意行为定位:
navigator.sendBeacon、图片像素外传(new Image().src)、chrome.storage 收集后批量上传([[re-netcap]] 衔接)chrome.scripting.executeScript;MV2 tabs.executeScript)、web_accessible_resources 开放页面供第三方站点调用addEventListener('keydown' 与 value 读取chrome.runtime.onInstalled / onStartup(安装/启动即跑)、chrome.alarms / setInterval(定时任务)、chrome.runtime.onMessage(消息驱动)——按触发点还原调用链,别只看顶层代码chrome.storage 或 IndexedDB 落地,别在全局变量里找持久状态混淆还原:
eval/动态加载);MV3 禁止远程代码(所有代码必须打包)——MV3 里出现远程拉取 = 审查绕过信号,重点标记grep -rniE 'http|sendBeacon|fetch|XMLHttpRequest|chrome\.' ext/ 扫全包;i18n 字符串在 _locales/*/messages.json(消息外衣下藏真实 URL 常见)更新机制与版本投毒:
update_url 自托管更新清单(XML 指向新 crx)是投毒入口;商店自动更新同理update_url 不生效——投毒面不同动态验证(沙箱):
chrome-extension://<id>/ 页面 F12)——配合断点看 service worker 内全局状态与网络调用chrome.storage/IndexedDB 落地数据background.service_worker 但 Firefox 里后台不跑;原因——Firefox MV3 不支持 service_worker 字段,用 background.scripts 事件页;对策——双字段写法(Chrome 用 service_worker、Firefox 用 scripts)按浏览器分别验证