GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — webstrike/docs/TECHNIQUE.md at main · ssrsec/webstrike

Expand file tree

/

TECHNIQUE.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
209 lines (153 loc) · 9.48 KB
/

TECHNIQUE.md

Copy path

File metadata and controls

209 lines (153 loc) · 9.48 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Chrome V3 扩展静默安装技术文档

概述

在不上架 Chrome Web Store、不加入企业域、不手动开启开发者模式的前提下,通过修改 Chrome 的 Secure Preferences / Preferences 文件并正确计算 HMAC 签名,实现扩展的自动安装与启用。

验证环境: Chrome 146.x,Windows(非域、默认关闭开发者模式)与 macOS(Apple 芯片 / Intel,默认关闭开发者模式)均已验证。macOS 侧须使用 IOPlatformUUID 作为 Device ID,并正确写入 account_values 镜像及对应 HMAC(见下文)。

核心原理

Chrome 使用 Secure Preferences (非域环境) 或 Preferences (域环境) 文件存储扩展配置。文件中的关键字段受 HMAC-SHA256 保护,防止外部篡改。我们需要:

  1. 写入扩展配置到 extensions.settings.<ext_id>
  2. 设置 extensions.ui.developer_mode = true,并在启用 Account Storage 时同步 account_values.extensions.ui.developer_mode
  3. 为上述节点(含 account_values 路径)分别计算正确的 HMAC
  4. 删除 Chrome 146+ 各处的 developer_mode_encrypted_hash(Windows 多为 DPAPI 语义,macOS 为 OSCrypt;删净后回退到 HMAC 校验)
  5. 重新计算 super_mac(对每个写入了 protection.macs 的偏好文件执行两次写入)

文件位置

Windows

环境 文件 路径
非域 Secure Preferences %LOCALAPPDATA%\Google\Chrome\User Data\Default\Secure Preferences
域 Preferences %LOCALAPPDATA%\Google\Chrome\User Data\Default\Preferences

macOS

文件 路径
Secure Preferences ~/Library/Application Support/Google/Chrome/<Profile>/Secure Preferences
Preferences ~/Library/Application Support/Google/Chrome/<Profile>/Preferences

实现上应对存在的上述两个文件一并修补(与 Windows 非域场景类似)。配置目录名一般为 Default,也可能为 Profile 1 等,需按实际 Profile 枚举。

HMAC 计算

种子 (Seed)

硬编码在 Chrome 的 resources.pak 文件中 (resource ID 146),自 Chrome 发布以来从未改变:

e748f336d85ea5f9dcdf25d8f347a65b4cdf667600f02df6724a2af18a212d26
b788a25086910cf3a90313696871f3dc05823730c91df8ba5c4fd9c884b505a8

其他浏览器的 seed:

  • Microsoft Edge: 空 (null)
  • Brave: 空 (null)

Device ID

  • Windows: 用户 SID 去掉最后一段 RID。例如 S-1-5-21-xxx-xxx-xxx-500 → S-1-5-21-xxx-xxx-xxx
  • macOS: 与 Chromium device_id_mac.cc 一致,使用 IOPlatformExpertDevice 的 IOPlatformUUID 字符串(与「关于本机」硬件 UUID 同源)。可通过 ioreg -rd1 -c IOPlatformExpertDevice 解析 "IOPlatformUUID",失败时再尝试 sysctl -n hw.uuid。不要使用 en0 MAC——与 Chrome 内部 HMAC 不一致时,偏好会被判无效,表现为扩展看似写入却无法启用。

参考: Chromium device_id_mac.cc

计算公式

HMAC-SHA256(
    key  = seed (64 bytes),
    data = device_id + pref_path + json_value
)

输出为大写十六进制字符串。

JSON 序列化规则

  1. 紧凑格式: separators=(',', ':'),无空格
  2. 不转义非 ASCII: ensure_ascii=False
  3. < 转义: 替换为 \u003C
  4. \u2122 还原: 替换为 ™ 字面量
  5. 去除空容器: 对 dict 类型的值,原地删除空 dict {}、空 list []、空字符串 "",但保留 False 和 0

super_mac 计算

HMAC-SHA256(
    key  = seed,
    data = device_id + json.dumps(data["protection"]["macs"])
)

注意:需要两次写入 — 先写入所有 MAC,然后读回文件计算 super_mac,再次写入。

Extension ID 计算

未打包扩展(从路径计算)

# Windows: UTF-16LE 编码路径
id_bytes = path.encode("utf-16-le")
# macOS: UTF-8 编码路径
id_bytes = path.encode("utf-8")

digest = SHA256(id_bytes).hexdigest()
ext_id = "".join("abcdefghijklmnop"[int(c, 16)] for c in digest[:32])

已签名扩展(从公钥计算)

digest = SHA256(public_key_der).hexdigest()
ext_id = "".join("abcdefghijklmnop"[int(c, 16)] for c in digest[:32])

如果 manifest.json 中包含 "key" 字段(base64 编码的 DER 公钥),Chrome 会使用公钥而非路径计算 ID,确保跨机器 ID 一致。

Secure Preferences 结构(简化)

{
    "extensions": {
        "settings": {
            "<ext_id>": { "...": "..." }
        },
        "ui": {
            "developer_mode": true
        }
    },
    "account_values": {
        "extensions": {
            "ui": {
                "developer_mode": true
            }
        }
    },
    "protection": {
        "macs": {
            "extensions": {
                "settings": {
                    "<ext_id>": "<HMAC>"
                },
                "ui": {
                    "developer_mode": "<HMAC>"
                }
            },
            "account_values": {
                "extensions": {
                    "ui": {
                        "developer_mode": "<HMAC>"
                    }
                }
            }
        },
        "super_mac": "<HMAC>"
    }
}

account_values 与开发者模式(macOS 必看)

桌面 Chrome 启用 Preferences Account Storage 时,Chromium 会为部分受跟踪 pref 再挂一条 account_values.<原路径> 镜像(见 chrome_pref_service_factory.cc 中 GetTrackingConfiguration 对 kAccountPreferencesPrefix 的克隆)。

对 extensions.ui.developer_mode 而言:

  • 根级需写入 account_values.extensions.ui.developer_mode = true
  • MAC 路径为 account_values.extensions.ui.developer_mode,写入 protection.macs.account_values.extensions.ui.developer_mode

若只改 extensions.ui 而删除或留空 account_values 镜像,合并后仍可能等价于「未开启开发者模式」,出现 「开启开发者模式即可使用此扩展程序…」。旧文档中「仅删除 account_values 下 developer_mode」在 macOS 上会导致该问题;正确做法是与主 pref 同步为 true 并单独计算上述 HMAC,同时去掉各处的 developer_mode_encrypted_hash。

未打包扩展在 macOS 上还可为 extensions.settings.<id> 写入 disable_reasons: 0、acknowledged: true,避免残留禁用位。

Chrome 146+ 新增防护: developer_mode_encrypted_hash

Chrome 146 起在 MAC 旁增加 developer_mode_encrypted_hash(由 OS 加密层保护的内容校验;Windows 上常称 DPAPI,macOS 上为 OSCrypt/Keychain 体系,字段名在 JSON 中仍相同),典型位置包括:

  • protection.macs.extensions.ui.developer_mode_encrypted_hash
  • protection.macs.account_values.extensions.ui.developer_mode_encrypted_hash

以及整棵 JSON 中其它嵌套路径下的同名键(实现上可对任意深度做 递归删除 developer_mode_encrypted_hash,避免平台/版本差异漏删)。

绕过方式

删除这些字段(不要留空占位)。缺失时 Chrome 会回退到与普通 pref 一致的 HMAC 校验;只要 developer_mode 与 account_values 镜像、super_mac 及各路 MAC 均正确即可接受。

若 encrypted_hash 仍存在且与当前布尔值不匹配,Chrome 会优先采信加密分支,忽略你写入的 HMAC,表现为开发者模式无法真正打开。

版本兼容性

Chrome 版本范围 developer_mode MAC 位置 encrypted_hash super_mac
< 134 protection.macs.extensions.ui.developer_mode 无 需要
134 - 145 protection.macs.extensions.ui.developer_mode 无 需要
146+ protection.macs.extensions.ui.developer_mode 及 protection.macs.account_values.extensions.ui.developer_mode 需要删除各路径 *_encrypted_hash 需要
  • Chrome < 134: 不需要为 developer_mode 计算 MAC,只需设置为 true 即可
  • Chrome 134+: 必须为 developer_mode 计算正确的 MAC(含启用 Account Storage 时的 account_values.extensions.ui.developer_mode 这一条路径的 MAC)
  • Chrome 146+: 额外需要递归/全面删除 developer_mode_encrypted_hash

完整操作流程

  1. 关闭 Chrome(Windows: taskkill /F /IM chrome.exe;macOS: pkill 等)
  2. 获取 Device ID(Windows:截断 SID;macOS:IOPlatformUUID)
  3. 枚举 Profile,对存在的 Secure Preferences 与 Preferences 分别处理(macOS 与 Windows 均可能两者皆有)
  4. 写入扩展配置 到 extensions.settings.<ext_id>(macOS 未打包扩展建议带 disable_reasons: 0、acknowledged: true)
  5. 设置 extensions.ui.developer_mode = true
  6. 设置 account_values.extensions.ui.developer_mode = true,并写入对应 protection.macs.account_values.extensions.ui.developer_mode(HMAC 的 pref 路径为 account_values.extensions.ui.developer_mode,值为 JSON 布尔 true 的序列化串,与主树一致)
  7. 计算扩展 HMAC → protection.macs.extensions.settings.<ext_id>
  8. 计算 developer_mode HMAC → protection.macs.extensions.ui.developer_mode
  9. 删除所有位置的 developer_mode_encrypted_hash(Chrome 146+,建议整文件递归删除该键名)
  10. 第一次写入偏好文件
  11. 读回文件,计算 super_mac → protection.super_mac
  12. 第二次写入
  13. 启动 Chrome
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.