<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-CN"><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://extrisha.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://extrisha.github.io/" rel="alternate" type="text/html" hreflang="zh-CN" /><updated>2026-11-20T19:18:19+08:00</updated><id>https://extrisha.github.io/feed.xml</id><title type="html">Welcome to my website!</title><subtitle>none</subtitle><author><name>victoirex</name></author><entry><title type="html">about .getAuthCode()</title><link href="https://extrisha.github.io/2026/11/12/about-.getauthcode/" rel="alternate" type="text/html" title="about .getAuthCode()" /><published>2026-11-12T00:03:00+08:00</published><updated>2026-11-12T00:03:00+08:00</updated><id>https://extrisha.github.io/2026/11/12/about-.getauthcode</id><content type="html" xml:base="https://extrisha.github.io/2026/11/12/about-.getauthcode/"><![CDATA[<h1 id="welink-hwh5getauthcode-调查总结">WeLink <code class="language-plaintext highlighter-rouge">HWH5.getAuthCode</code> 调查总结</h1>

<p><strong>目标程序</strong>：WeLink（Electron 桌面客户端）
<code class="language-plaintext highlighter-rouge">C:\Program Files (x86)\WeLink\WeLink.exe</code>，sha256 <code class="language-plaintext highlighter-rouge">e744c698…</code></p>

<p><strong>调查目的</strong>：搞清楚 <code class="language-plaintext highlighter-rouge">HWH5.getAuthCode()</code> 端到端怎么工作（网页接口 → 桥 → 宿主 → 服务端），以及这张”授权码”到底从哪来、由谁签发，从而为自己应用设计一套等价实现。</p>

<p><strong>约束</strong>：以静态分析为主；只在用户明确同意后运行过一次程序；不复制专有代码；<strong>不记录任何真实凭据值</strong>（本文所有涉及凭据的地方只写长度和形状）。</p>

<hr />

<h2 id="一一句话结论">一、一句话结论</h2>

<p><code class="language-plaintext highlighter-rouge">HWH5.getAuthCode()</code> 不是”计算出”一张码，而是<strong>向服务端要</strong>一张码：网页侧只是一个请求/回调的薄壳，宿主进程收到请求后去打一个 SSO 接口取票，再把票原样递回页面。<strong>码由服务端签发，客户端只做中转，且每次调用都新签一张不同的票。</strong></p>

<hr />

<h2 id="二调查做了什么">二、调查做了什么</h2>

<table>
  <thead>
    <tr>
      <th>阶段</th>
      <th>动作</th>
      <th>结果</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>识别程序类型</td>
      <td>Electron 外壳 + 大量原生 DLL；网页代码在 <code class="language-plaintext highlighter-rouge">app.asar</code> 与 <code class="language-plaintext highlighter-rouge">plugin/business</code> 内的 zip 里</td>
    </tr>
    <tr>
      <td>2</td>
      <td>解包并定位网页 SDK</td>
      <td><code class="language-plaintext highlighter-rouge">hwh5.js</code>（268 KB）、<code class="language-plaintext highlighter-rouge">wecodeJsapiSdk.js</code>（1.07 MB）、<code class="language-plaintext highlighter-rouge">preload.js</code>、<code class="language-plaintext highlighter-rouge">api_mapping.json</code></td>
    </tr>
    <tr>
      <td>3</td>
      <td>静态追链路</td>
      <td>逐跳定位到宿主处理者与服务端接口（见第三节）</td>
    </tr>
    <tr>
      <td>4</td>
      <td>尝试运行观察</td>
      <td>首次尝试失败（调试端口被 Electron 保险丝关闭，<code class="language-plaintext highlighter-rouge">fnd_13</code>）</td>
    </tr>
    <tr>
      <td>5</td>
      <td>改用日志取证</td>
      <td>读取客户端自身日志，得到登录时序、隧道时序、请求记录</td>
    </tr>
    <tr>
      <td>6</td>
      <td>用户打开一个 WeCode 小程序</td>
      <td><strong>完整调用链在运行日志中逐条出现</strong>，取得真实响应形状</td>
    </tr>
    <tr>
      <td>7</td>
      <td>本地比对两张票</td>
      <td>两次调用得到的票<strong>不同</strong>，确认逐次签发</td>
    </tr>
  </tbody>
</table>

<blockquote>
  <p>说明：第 6 步由用户手动操作触发；第 7 步的比较由用户在本机执行，只报告了”相同/不同”的结论，值未离开本机。</p>
</blockquote>

<hr />

<h2 id="三完整调用链静态--实测一致">三、完整调用链（静态 + 实测一致）</h2>

<h3 id="31-逐跳路径">3.1 逐跳路径</h3>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>① 页面 JS
   HWH5.getAuthCode({ clientId })              // clientId = 第三方应用注册的 appid
      ↓  通用信封
② HWH5.callMethod(JSON.stringify({
        funcName: "getAuthCode", data: {clientId}, callbackId }))
      ↓  Electron webview 通道
③ preload.js
   ipcRenderer.sendToHost("preload:getAuthCode")
      ↓
④ 宿主页面（wecodeJsapiSdk.js）
   webview.on("ipc-message") → getChannelMap()["preload:getAuthCode"]
      → this.getAuthCode(winId)
      ↓  一次服务端调用
⑤ POST https://{middleEndAddress}/mcloud/mag/ProxyForText/ssoauth/v1/code
      （GET_PUBLIC_NOURL_CODE，无请求体，带 getAuthHeader() 的会话头）
      ↓
⑥ r = recv_body.code || ""          // 空则记错误并回空串
      ↓
⑦ webContents.send("preload:authCode", r)
      ↓
⑧ 页面回调 HWH5.callbackNative(JSON.stringify({
        callbackId, data: base64(UTF-8 JSON) }))
   → 按 callbackId 配对，回调收到 { code }
</code></pre></div></div>

<h3 id="32-运行日志逐条印证">3.2 运行日志逐条印证</h3>

<p>用户打开审批类 WeCode 应用后，客户端日志按顺序记录（<code class="language-plaintext highlighter-rouge">fnd_37</code>）：</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>.053  getJsapiHighriskList {openCheck:true, checkLevel:1} ["fetch","getUserInfo"]
.053  jsapi is not highrisk getAuthCode          ← 权限/风控门放行
.053  ipc-channel#winId-5: preload:getJsapiControl
.054  preload:logger
.054  [WARN] funcName: getAuthCode               ← 页面确实调用了
.054  ipc-channel#winId-5: preload:getAuthCode   ← 桥上通行
.054  middleGroundUrlMap  isRedblue:false  getMiddleGroundUrl: GET_PUBLIC_NOURL_CODE
.055  _requestMiddleGround getPublicNOUrlCode  https://api.welink…/ext/ssoauth/v1/code
.059  loadHttpLibrary start http_with_rs.dll     ← 原生 HTTP 栈按需加载
.490  commonRequest #result: 423ms
.490  _dealWithRequestResult: resp_code=200, result=1
.490  dealWithRequestResult: code=&lt;值&gt;, message=undefined
.492  reply 路径继续（preload:Return_App_Type…）
</code></pre></div></div>

<p><strong>静态分析推断的每一跳，运行日志里都出现且顺序一致。</strong></p>

<h3 id="33-网页侧契约可直接照抄的形状">3.3 网页侧契约（可直接照抄的形状）</h3>

<table>
  <thead>
    <tr>
      <th>项目</th>
      <th>值</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>全局对象</td>
      <td><code class="language-plaintext highlighter-rouge">HWH5</code> 或 <code class="language-plaintext highlighter-rouge">HWH5PB</code></td>
    </tr>
    <tr>
      <td>方法名</td>
      <td><code class="language-plaintext highlighter-rouge">getAuthCode</code></td>
    </tr>
    <tr>
      <td>入参</td>
      <td><code class="language-plaintext highlighter-rouge">{ clientId: string }</code>（必填）</td>
    </tr>
    <tr>
      <td>返回</td>
      <td><code class="language-plaintext highlighter-rouge">{ code: string }</code></td>
    </tr>
    <tr>
      <td>信封</td>
      <td><code class="language-plaintext highlighter-rouge">callMethod({funcName, data, callbackId})</code></td>
    </tr>
    <tr>
      <td>回执</td>
      <td><code class="language-plaintext highlighter-rouge">callbackNative({callbackId, data: base64(UTF-8 JSON)})</code></td>
    </tr>
    <tr>
      <td>SDK 自述</td>
      <td>「免登1.0」</td>
    </tr>
    <tr>
      <td>能力分类</td>
      <td><code class="language-plaintext highlighter-rouge">serviceAuthorization</code>（不在通用 <code class="language-plaintext highlighter-rouge">public</code> 列表）</td>
    </tr>
    <tr>
      <td>失败码</td>
      <td><code class="language-plaintext highlighter-rouge">70002</code>（We码）/ <code class="language-plaintext highlighter-rouge">70003</code>（第三方应用）；权限缺失为 <code class="language-plaintext highlighter-rouge">NoPermission</code></td>
    </tr>
  </tbody>
</table>

<hr />

<h2 id="四这张票的事实">四、这张”票”的事实</h2>

<table>
  <thead>
    <tr>
      <th>项目</th>
      <th>结论</th>
      <th>依据</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>形状</td>
      <td><strong>96 位大写十六进制字符</strong>（= 48 字节）</td>
      <td><code class="language-plaintext highlighter-rouge">fnd_38</code></td>
    </tr>
    <tr>
      <td>外壳</td>
      <td><strong>裸值</strong>，无包裹对象；<code class="language-plaintext highlighter-rouge">result=1</code> 表示成功，<code class="language-plaintext highlighter-rouge">message=undefined</code></td>
      <td><code class="language-plaintext highlighter-rouge">fnd_38</code></td>
    </tr>
    <tr>
      <td>是否告知寿命</td>
      <td><strong>否</strong>。响应里没有任何过期字段</td>
      <td><code class="language-plaintext highlighter-rouge">fnd_41</code></td>
    </tr>
    <tr>
      <td>是否逐次签发</td>
      <td><strong>是</strong>。相隔约 11 秒的两次调用值不同</td>
      <td><code class="language-plaintext highlighter-rouge">fnd_42</code></td>
    </tr>
    <tr>
      <td>客户端是否缓存</td>
      <td><strong>否</strong>。处理者每次现取，无 memo</td>
      <td><code class="language-plaintext highlighter-rouge">fnd_40</code></td>
    </tr>
    <tr>
      <td>客户端是否兑换</td>
      <td><strong>否</strong>。两个 SDK 里都没有针对这张票的兑换代码</td>
      <td><code class="language-plaintext highlighter-rouge">fnd_40</code></td>
    </tr>
    <tr>
      <td>兑换地点</td>
      <td><strong>小程序自己的后端，服务端到服务端</strong></td>
      <td><code class="language-plaintext highlighter-rouge">fnd_40</code></td>
    </tr>
    <tr>
      <td>往返耗时</td>
      <td>423 ms（含原生 HTTP 栈首次加载开销）</td>
      <td><code class="language-plaintext highlighter-rouge">fnd_38</code></td>
    </tr>
  </tbody>
</table>

<h3 id="41-一个对照说明设计意图">4.1 一个对照，说明设计意图</h3>

<p>同一个 SDK 里，第三方应用换到的 <strong>JWT 是带寿命的，而且被认真执行</strong>（<code class="language-plaintext highlighter-rouge">fnd_41</code>）：</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>缓存在 welink_roma_auth_&lt;appid&gt;：{ time, jwt }
判过期：  time + 1000 * parseInt(jwt.expire_in) &lt; Date.now()  → 重新获取
</code></pre></div></div>

<p>而这张 auth code <strong>什么字段都不给</strong>。差别不是疏漏，是态度：<strong>票就是给你立刻用掉的。</strong></p>

<h3 id="42-两种码不要混">4.2 两种”码”不要混</h3>

<table>
  <thead>
    <tr>
      <th>用途</th>
      <th>端点</th>
      <th>返回读取方式</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>H5 页面取票（本文主题）</td>
      <td><code class="language-plaintext highlighter-rouge">POST …/ssoauth/v1/code</code></td>
      <td>读 <code class="language-plaintext highlighter-rouge">recv_body.code</code></td>
    </tr>
    <tr>
      <td>WeCode 专用</td>
      <td><code class="language-plaintext highlighter-rouge">POST …/sso/auth/v2/code</code></td>
      <td>要求 <code class="language-plaintext highlighter-rouge">code === "0"</code>，读 <code class="language-plaintext highlighter-rouge">recv_body.auth_code</code></td>
    </tr>
    <tr>
      <td>免登录跳转</td>
      <td><code class="language-plaintext highlighter-rouge">getExemptionCode</code> → <code class="language-plaintext highlighter-rouge">https://login.&lt;host&gt;/sso/auth/v1/code/session?code=…&amp;targetUrl=…</code></td>
      <td>—</td>
    </tr>
    <tr>
      <td>第三方换 JWT</td>
      <td><code class="language-plaintext highlighter-rouge">POST {该应用自己的域名}/jwt/token</code>，体 <code class="language-plaintext highlighter-rouge">{appid, sso:"welink", token}</code></td>
      <td>读 <code class="language-plaintext highlighter-rouge">access_token</code> / <code class="language-plaintext highlighter-rouge">token_type</code></td>
    </tr>
  </tbody>
</table>

<hr />

<h2 id="五身份与会话从哪来">五、身份与会话从哪来</h2>

<ul>
  <li>所有能力调用都走同一个代理主机：<code class="language-plaintext highlighter-rouge">https://{middleEndAddress}/mcloud/mag/ProxyForText/…</code>，实测主机为 <code class="language-plaintext highlighter-rouge">https://api.welink.huaweicloud.com</code>（<code class="language-plaintext highlighter-rouge">fnd_16</code>）。</li>
  <li>请求头由 <code class="language-plaintext highlighter-rouge">getAuthHeader()</code> 生成，其内容来自原生层的一次方法调用（<code class="language-plaintext highlighter-rouge">fnd_19</code>、<code class="language-plaintext highlighter-rouge">fnd_20</code>）：</li>
</ul>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>getAuthorizationInfo():
    { middle_ground_onebox_cookie, middle_ground_token }
       = Pedestal.callMethod("method://pedestal/getCurrLoginStatus", { entry: "headers" })


getAuthHeader():
    if (window.isRedblue) return { Cookie }
    return { Cookie: "token=" + token, "x-wlk-Authorization": token }
</code></pre></div></div>

<ul>
  <li><code class="language-plaintext highlighter-rouge">getCurrLoginStatus</code> 是<strong>按需调用</strong>，没有定时器；唯一刷新机制是 401 → <code class="language-plaintext highlighter-rouge">refreshMiddleGroundToken()</code>（<code class="language-plaintext highlighter-rouge">fnd_26</code>）。</li>
  <li><strong>token 会直接交给页面 JS</strong>（<code class="language-plaintext highlighter-rouge">fnd_19</code>）。这是一个客观存在的暴露面。</li>
</ul>

<h3 id="51-登录一次拿到全部地址">5.1 登录一次，拿到全部地址</h3>

<p>登录成功那一条日志等于一份完整会话说明书（<code class="language-plaintext highlighter-rouge">fnd_35</code>）：</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>loginStatus              = 2
middleGroundToken.len    = 36
oneboxaddress            = space.welink.huaweicloud.com      ← 云盘
maaUri                   = im.welink.huaweicloud.com:443     ← 隧道入口
meetingLoginUrl          = bmeeting.huaweicloud.com          ← 会议
middleGroundSsoLoginUrl  = https://login…/sso/auth/v1/code/session?code=($innercode)&amp;targetUrl=
HMneus.len               = 1489                              ← 工作台应用菜单
m_middleGroundConfiguration = { 卡片 AppId、上报地址、会议相关配置 }
</code></pre></div></div>

<p><strong>客户端之所以”不需要身份逻辑”，是因为它从来不需要判断”我是谁”——服务端一次性告诉它去哪、用什么凭证。</strong></p>

<hr />

<h2 id="六tup--隧道-与这张票的真实关系">六、TUP / 隧道 与这张票的真实关系</h2>

<p>这是本次最容易误解的一点，结论明确：</p>

<h3 id="61-票不经过隧道隧道反而需要票">6.1 票不经过隧道；隧道反而需要票</h3>

<p><code class="language-plaintext highlighter-rouge">pedestal/wk_login.log</code> 的时间顺序（<code class="language-plaintext highlighter-rouge">fnd_34</code>）：</p>

<table>
  <thead>
    <tr>
      <th>时刻</th>
      <th>事件</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>22:51:00.703</td>
      <td><code class="language-plaintext highlighter-rouge">loginStatus = 0</code>，<code class="language-plaintext highlighter-rouge">middleGroundToken.len = 0</code>，<code class="language-plaintext highlighter-rouge">maaUri</code> 为空</td>
    </tr>
    <tr>
      <td><strong>22:51:09.069</strong></td>
      <td><code class="language-plaintext highlighter-rouge">loginStatus = 2</code>，<code class="language-plaintext highlighter-rouge">middleGroundToken.len = 36</code>，<code class="language-plaintext highlighter-rouge">maaUri = im.welink.huaweicloud.com:443</code></td>
    </tr>
    <tr>
      <td>22:51:09.941</td>
      <td>IM 侧 <code class="language-plaintext highlighter-rouge">authToken.len = 36</code> → <code class="language-plaintext highlighter-rouge">need login</code></td>
    </tr>
    <tr>
      <td>22:51:10.013</td>
      <td>隧道才开始 TLS 握手</td>
    </tr>
    <tr>
      <td>22:51:10.181</td>
      <td>隧道发出登录请求</td>
    </tr>
  </tbody>
</table>

<p><strong>token 比隧道的第一条连接早将近 1 秒</strong>，且隧道登录本身要用这个 token → <strong>通道不可能产出它。</strong></p>

<h3 id="62-取票也不走隧道">6.2 取票也不走隧道</h3>

<p>取票那一步加载的是 <code class="language-plaintext highlighter-rouge">http_with_rs.dll</code>（普通 HTTPS 栈），与 IM 长连接无关（<code class="language-plaintext highlighter-rouge">fnd_38</code>）。</p>

<h3 id="63-tup-的两种面孔不要混">6.3 TUP 的两种”面孔”不要混</h3>

<table>
  <thead>
    <tr>
      <th> </th>
      <th>载体</th>
      <th>通道</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>TUP HTTP 接口</td>
      <td>TUP 库</td>
      <td><strong>普通 HTTPS</strong>（登录、业务、取票都走这里）</td>
    </tr>
    <tr>
      <td>TUP 长连接（隧道）</td>
      <td>TUP</td>
      <td>私有协议，目标为 <code class="language-plaintext highlighter-rouge">maaUri</code></td>
    </tr>
  </tbody>
</table>

<p>“经过 TUP” ≠ “经过私有隧道”。</p>

<h3 id="64-隧道自身的传输安全客观测量">6.4 隧道自身的传输安全（客观测量）</h3>

<table>
  <thead>
    <tr>
      <th>项目</th>
      <th>结论</th>
      <th>依据</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>证书校验</td>
      <td><strong>开启</strong>：<code class="language-plaintext highlighter-rouge">should_verify = 1</code></td>
      <td><code class="language-plaintext highlighter-rouge">fnd_30</code></td>
    </tr>
    <tr>
      <td>实际校验链</td>
      <td><code class="language-plaintext highlighter-rouge">*.welink.huaweicloud.com</code> → GlobalSign RSA OV SSL CA 2018 → GlobalSign Root CA - R3，逐级 <code class="language-plaintext highlighter-rouge">preverified success</code></td>
      <td><code class="language-plaintext highlighter-rouge">fnd_30</code></td>
    </tr>
    <tr>
      <td>信任库</td>
      <td><strong>自带</strong> OpenSSL 哈希式证书目录，<strong>不认 Windows 证书库</strong>（装企业根证书拦不住它）</td>
      <td><code class="language-plaintext highlighter-rouge">fnd_31</code></td>
    </tr>
    <tr>
      <td>协议栈</td>
      <td>静态链接 OpenSSL 3.0.16，版本表含 TLS 1.3/1.2/1.1/1.0 与 DTLS/QUIC</td>
      <td><code class="language-plaintext highlighter-rouge">fnd_31</code></td>
    </tr>
    <tr>
      <td>载荷加密</td>
      <td><strong>只有 TLS 一层</strong>（未发现应用层加密迹象）</td>
      <td><code class="language-plaintext highlighter-rouge">fnd_33</code></td>
    </tr>
    <tr>
      <td>信任库卫生</td>
      <td>目录内有一份自签 CA（<code class="language-plaintext highlighter-rouge">CN=www.example.com</code>，O=Huawei，有效期至 2099，CA:TRUE，注释指向交换机产品线），<strong>是否被加载未证</strong></td>
      <td><code class="language-plaintext highlighter-rouge">fnd_32</code>、<code class="language-plaintext highlighter-rouge">unk_68b136…</code></td>
    </tr>
  </tbody>
</table>

<p><strong>评价</strong>：在”防窃听、防假冒服务器”这件事上，这一层做得实在；但它<strong>不提供任何”客户端可信”的保证</strong>，那从来不是它的职责。</p>

<hr />

<h2 id="七客户端加固与暴露面">七、客户端加固与暴露面</h2>

<h3 id="71-已做的加固">7.1 已做的加固</h3>

<ul>
  <li>Electron 保险丝：<code class="language-plaintext highlighter-rouge">EnableNodeCliInspectArguments</code> <strong>关闭</strong>（<code class="language-plaintext highlighter-rouge">--inspect</code> 无效），<code class="language-plaintext highlighter-rouge">OnlyLoadAppFromAsar</code> 开启（<code class="language-plaintext highlighter-rouge">fnd_13</code>）。
  <strong>实测后果</strong>：三次尝试附加调试端口全部 connection refused，运行观察只能改走日志。</li>
  <li>API 分级：<code class="language-plaintext highlighter-rouge">getAuthCode</code> 被归入”服务授权”而非通用能力（<code class="language-plaintext highlighter-rouge">fnd_8</code>）；调用前过权限表与风控名单，实测 <code class="language-plaintext highlighter-rouge">openCheck:true</code> 生效（<code class="language-plaintext highlighter-rouge">fnd_37</code>）。</li>
  <li>传输：自带根证书，不信任操作系统证书库（<code class="language-plaintext highlighter-rouge">fnd_31</code>）。</li>
</ul>

<h3 id="72-客观存在的暴露面">7.2 客观存在的暴露面</h3>

<table>
  <thead>
    <tr>
      <th>暴露面</th>
      <th>事实</th>
      <th>依据</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>凭据明文落盘</td>
      <td>取票响应把票<strong>原样写进日志</strong>，而同一个日志里 URL 却被 35 个 <code class="language-plaintext highlighter-rouge">*</code> 打码</td>
      <td><code class="language-plaintext highlighter-rouge">fnd_39</code></td>
    </tr>
    <tr>
      <td>票新鲜且先到先得</td>
      <td>每调一次新签一张，落在日志里的票都处于寿命开头</td>
      <td><code class="language-plaintext highlighter-rouge">fnd_42</code></td>
    </tr>
    <tr>
      <td>token 交给页面</td>
      <td><code class="language-plaintext highlighter-rouge">getAuthHeader()</code> 把会话 token 返回给页面 JS</td>
      <td><code class="language-plaintext highlighter-rouge">fnd_19</code></td>
    </tr>
    <tr>
      <td>会话无绑定证据</td>
      <td>未见 nonce / deviceId / 请求签名；会话为长寿命 bearer</td>
      <td><code class="language-plaintext highlighter-rouge">fnd_24</code></td>
    </tr>
    <tr>
      <td>日志信息量大</td>
      <td>设备名、IP、证书主题、连接五元组、重试参数均明文</td>
      <td><code class="language-plaintext highlighter-rouge">fnd_28</code></td>
    </tr>
  </tbody>
</table>

<p><strong>注</strong>：以上只陈述观察到的现象，不构成对漏洞的断言；”没看到”不等于”不存在”。</p>

<hr />

<h2 id="八验证矩阵">八、验证矩阵</h2>

<h3 id="已证明观察">已证明（观察）</h3>

<ul>
  <li>完整调用链存在且顺序与静态分析一致（<code class="language-plaintext highlighter-rouge">fnd_37</code>）</li>
  <li>票为 96 位大写十六进制裸值（<code class="language-plaintext highlighter-rouge">fnd_38</code>）</li>
  <li>每次调用新签一张，值不同（<code class="language-plaintext highlighter-rouge">fnd_42</code>，来自用户本机比对）</li>
  <li>取票走普通 HTTPS，不经隧道（<code class="language-plaintext highlighter-rouge">fnd_38</code>）</li>
  <li>token 早于隧道建立，隧道登录依赖 token（<code class="language-plaintext highlighter-rouge">fnd_34</code>）</li>
  <li>隧道 TLS 校验开启且链路完整（<code class="language-plaintext highlighter-rouge">fnd_30</code>）</li>
  <li>客户端使用自带 CA 目录（<code class="language-plaintext highlighter-rouge">fnd_31</code>）</li>
  <li>凭据明文写入日志而 URL 被打码（<code class="language-plaintext highlighter-rouge">fnd_39</code>）</li>
</ul>

<h3 id="推论由观察算出">推论（由观察算出）</h3>

<ul>
  <li>票由服务端签发，客户端无法自造（<code class="language-plaintext highlighter-rouge">fnd_9</code>、<code class="language-plaintext highlighter-rouge">fnd_40</code>）</li>
  <li>票的设计意图是”立即使用”（无过期字段 + 逐次签发 + 无缓存）</li>
  <li>因为信任边界在服务端，客户端”不设防”才成立；这与传输层是否牢固是两件事</li>
</ul>

<h3 id="未知">未知</h3>

<table>
  <thead>
    <tr>
      <th>编号</th>
      <th>内容</th>
      <th>状态</th>
      <th>如何关闭</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">unk_63ffb4…</code></td>
      <td>票的<strong>确切寿命</strong>、是否<strong>一次性</strong></td>
      <td>blocked</td>
      <td>用自己在自有租户注册的 appid 做少量兑换测试；或查厂商文档。<strong>不要拿日志里的票打生产鉴权</strong></td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">unk_ad5d2b…</code></td>
      <td><code class="language-plaintext highlighter-rouge">getCurrLoginStatus</code> 完整字段集；token 磁盘落地方式</td>
      <td>open</td>
      <td>静态追 <code class="language-plaintext highlighter-rouge">method://pedestal</code> 路由到原生实现；或查 KMC/DPAPI 存储</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">unk_cf3e39…</code></td>
      <td>服务端是否做设备/客户端绑定</td>
      <td>open</td>
      <td>需要书面授权才能测；客户端侧看不到</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">unk_68b136…</code></td>
      <td>那份自签 CA 是否真的被加载</td>
      <td>open</td>
      <td>运行时观察该目录是否被读取；或问厂商</td>
    </tr>
  </tbody>
</table>

<p><strong>为什么寿命测不了</strong>：客户端从不兑换这张票，本机没有任何合法兑换端点可用。兑换发生在小程序后端，需要”服务端认可的 appid + 该应用自己的域名”。</p>

<hr />

<h2 id="九对复刻的可用结论">九、对复刻的可用结论</h2>

<h3 id="91-设计原则从证据反推">9.1 设计原则（从证据反推）</h3>

<ol>
  <li><strong>票只由服务端签发</strong>，客户端每一侧都无权自造。</li>
  <li><strong>客户端不缓存</strong>，每次现取——简化了失效处理，也缩短了重放窗口。</li>
  <li><strong>不告知寿命</strong>，语义上等于”立刻用”。</li>
  <li><strong>兑换只发生在服务端之间</strong>，浏览器永不做兑换。</li>
  <li><strong>票绑定”请求它的那个 clientId”</strong>，而不是绑定某张长期会话。</li>
</ol>

<h3 id="92-建议规格">9.2 建议规格</h3>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>POST /auth/v1/code
  入参   { clientId }                    // 应用注册 id，必填
  出参   { code }                        // 不透明，不给 expire_in
  规则   60 秒有效 / 一次性 / 绑定 clientId + 当前会话
  限制   每个 clientId 每分钟限量，防批量铸票


POST /auth/v1/token                     // 仅服务端到服务端
  入参   { appId, sso: "sso", code }
  出参   { access_token, token_type, expire_in }
  规则   兑换即作废；同一 code 二次兑换返回明确错误
</code></pre></div></div>

<h3 id="93-参考实现骨架伪代码">9.3 参考实现骨架（伪代码）</h3>

<p><strong>主进程（Node / Electron main）</strong></p>

<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">ipcMain</span><span class="p">.</span><span class="nx">handle</span><span class="p">(</span><span class="dl">"</span><span class="s2">auth:code</span><span class="dl">"</span><span class="p">,</span> <span class="k">async</span> <span class="p">(</span><span class="nx">event</span><span class="p">,</span> <span class="p">{</span> <span class="nx">clientId</span> <span class="p">})</span> <span class="o">=&gt;</span> <span class="p">{</span>
<span class="err"> </span> <span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">clientId</span> <span class="o">!==</span> <span class="dl">"</span><span class="s2">string</span><span class="dl">"</span> <span class="o">||</span> <span class="o">!</span><span class="nx">clientId</span><span class="p">)</span> <span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="dl">"</span><span class="s2">bad clientId</span><span class="dl">"</span><span class="p">);</span>
<span class="err"> </span> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">session</span><span class="p">.</span><span class="nx">isLoggedIn</span><span class="p">(</span><span class="nx">event</span><span class="p">.</span><span class="nx">senderFrame</span><span class="p">))</span> <span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="dl">"</span><span class="s2">not signed in</span><span class="dl">"</span><span class="p">);</span>
<span class="err"> </span> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">rateLimit</span><span class="p">.</span><span class="nx">take</span><span class="p">(</span><span class="nx">clientId</span><span class="p">))</span> <span class="err"> </span> <span class="err"> </span> <span class="err"> </span> <span class="err"> </span> <span class="err"> </span> <span class="err"> </span><span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="dl">"</span><span class="s2">rate limited</span><span class="dl">"</span><span class="p">);</span>


<span class="err"> </span> <span class="kd">const</span> <span class="nx">r</span> <span class="o">=</span> <span class="k">await</span> <span class="nx">fetch</span><span class="p">(</span><span class="s2">`</span><span class="p">${</span><span class="nx">cfg</span><span class="p">.</span><span class="nx">baseUrl</span><span class="p">}</span><span class="s2">/auth/v1/code`</span><span class="p">,</span> <span class="p">{</span>
<span class="err"> </span> <span class="err"> </span> <span class="na">method</span><span class="p">:</span> <span class="dl">"</span><span class="s2">POST</span><span class="dl">"</span><span class="p">,</span>
<span class="err"> </span> <span class="err"> </span> <span class="na">headers</span><span class="p">:</span> <span class="p">{</span> <span class="dl">"</span><span class="s2">Content-Type</span><span class="dl">"</span><span class="p">:</span> <span class="dl">"</span><span class="s2">application/json</span><span class="dl">"</span><span class="p">,</span> <span class="p">...</span><span class="nx">session</span><span class="p">.</span><span class="nx">headers</span><span class="p">()</span> <span class="p">},</span>
<span class="err"> </span> <span class="err"> </span> <span class="na">body</span><span class="p">:</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">({</span> <span class="nx">clientId</span> <span class="p">}),</span>
<span class="err"> </span> <span class="p">});</span>
<span class="err"> </span> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">r</span><span class="p">.</span><span class="nx">ok</span><span class="p">)</span> <span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="s2">`auth code failed: </span><span class="p">${</span><span class="nx">r</span><span class="p">.</span><span class="nx">status</span><span class="p">}</span><span class="s2">`</span><span class="p">);</span>
<span class="err"> </span> <span class="kd">const</span> <span class="p">{</span> <span class="nx">code</span> <span class="p">}</span> <span class="o">=</span> <span class="k">await</span> <span class="nx">r</span><span class="p">.</span><span class="nx">json</span><span class="p">();</span>
<span class="err"> </span> <span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">code</span><span class="p">)</span> <span class="k">throw</span> <span class="k">new</span> <span class="nb">Error</span><span class="p">(</span><span class="dl">"</span><span class="s2">empty code</span><span class="dl">"</span><span class="p">);</span>


<span class="err"> </span> <span class="nx">log</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="dl">"</span><span class="s2">auth code issued</span><span class="dl">"</span><span class="p">,</span> <span class="p">{</span> <span class="nx">clientId</span><span class="p">,</span> <span class="na">len</span><span class="p">:</span> <span class="nx">code</span><span class="p">.</span><span class="nx">length</span> <span class="p">});</span> <span class="c1">// 只记元数据</span>
<span class="err"> </span> <span class="k">return</span> <span class="p">{</span> <span class="nx">code</span> <span class="p">};</span>
<span class="p">});</span>
</code></pre></div></div>

<p><strong>渲染进程 / preload（窄接口，页面拿不到会话）</strong></p>

<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nx">contextBridge</span><span class="p">.</span><span class="nx">exposeInMainWorld</span><span class="p">(</span><span class="dl">"</span><span class="s2">Auth</span><span class="dl">"</span><span class="p">,</span> <span class="p">{</span>
<span class="err"> </span> <span class="na">getAuthCode</span><span class="p">:</span> <span class="p">(</span><span class="nx">clientId</span><span class="p">)</span> <span class="o">=&gt;</span> <span class="nx">ipcRenderer</span><span class="p">.</span><span class="nx">invoke</span><span class="p">(</span><span class="dl">"</span><span class="s2">auth:code</span><span class="dl">"</span><span class="p">,</span> <span class="p">{</span> <span class="nx">clientId</span> <span class="p">}),</span>
<span class="p">});</span>
</code></pre></div></div>

<h3 id="94-与-welink-的关键差异建议之处">9.4 与 WeLink 的关键差异（建议之处）</h3>

<table>
  <thead>
    <tr>
      <th>项目</th>
      <th>WeLink 做法</th>
      <th>建议做法</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>会话 token 给页面</td>
      <td>给（<code class="language-plaintext highlighter-rouge">getAuthHeader</code> 返回 token）</td>
      <td><strong>不给</strong>，只在主进程持有</td>
    </tr>
    <tr>
      <td>凭据进日志</td>
      <td>明文（<code class="language-plaintext highlighter-rouge">fnd_39</code>）</td>
      <td><strong>只记长度/长度区间</strong>，或哈希前 8 位</td>
    </tr>
    <tr>
      <td>票寿命告知</td>
      <td>不告知</td>
      <td>可在服务端记录以便审计，仍不返回给客户端</td>
    </tr>
    <tr>
      <td>兑换位置</td>
      <td>服务端之间</td>
      <td>同（保持不变，这是正确做法）</td>
    </tr>
    <tr>
      <td>设备绑定</td>
      <td>未见证据</td>
      <td>加 nonce 或设备指纹，至少对高风险接口</td>
    </tr>
  </tbody>
</table>

<hr />

<h2 id="十方法说明与可信度">十、方法说明与可信度</h2>

<ul>
  <li>结论分三级标注：<strong>观察</strong>（直接读到）、<strong>推论</strong>（由观察算出）、<strong>未知</strong>。</li>
  <li>每条事实对应一个证据编号（<code class="language-plaintext highlighter-rouge">fnd_N</code>），证据包含原始工具输出与文件偏移。</li>
  <li>静态分析不能证明代码”实际被执行”；本文中所有”实际运行”的结论均来自客户端自身日志，并注明触发时间。</li>
  <li>未找到某字符串只说明”搜索范围内没找到”，本文在相应位置写明了搜索范围。</li>
</ul>

<h3 id="关键证据索引">关键证据索引</h3>

<table>
  <thead>
    <tr>
      <th>主题</th>
      <th>证据</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>网页侧契约</td>
      <td><code class="language-plaintext highlighter-rouge">ev_cc575726…</code>、<code class="language-plaintext highlighter-rouge">ev_2b0df914…</code>、<code class="language-plaintext highlighter-rouge">ev_5d23bbd4…</code></td>
    </tr>
    <tr>
      <td>宿主处理者</td>
      <td><code class="language-plaintext highlighter-rouge">ev_8f8348abf3c…</code>、<code class="language-plaintext highlighter-rouge">ev_2ba0946c637…</code></td>
    </tr>
    <tr>
      <td>取票端点</td>
      <td><code class="language-plaintext highlighter-rouge">ev_7da6c514108…</code>、<code class="language-plaintext highlighter-rouge">ev_985e2607613…</code></td>
    </tr>
    <tr>
      <td>鉴权与门禁</td>
      <td><code class="language-plaintext highlighter-rouge">ev_50c449617da…</code>、<code class="language-plaintext highlighter-rouge">ev_5669c05c711…</code>、<code class="language-plaintext highlighter-rouge">ev_21002e77b6b…</code></td>
    </tr>
    <tr>
      <td>身份与头</td>
      <td><code class="language-plaintext highlighter-rouge">ev_fb83ec749b4…</code>、<code class="language-plaintext highlighter-rouge">ev_3bf96c24145…</code></td>
    </tr>
    <tr>
      <td>保险丝</td>
      <td><code class="language-plaintext highlighter-rouge">ev_b7c6188eb84…</code></td>
    </tr>
    <tr>
      <td>登录时序</td>
      <td><code class="language-plaintext highlighter-rouge">ev_a18a027004db…</code>、<code class="language-plaintext highlighter-rouge">ev_d7d19a7b7528…</code></td>
    </tr>
    <tr>
      <td>隧道 TLS</td>
      <td><code class="language-plaintext highlighter-rouge">ev_056172fd6b8…</code>、<code class="language-plaintext highlighter-rouge">ev_9260642e857…</code>、<code class="language-plaintext highlighter-rouge">ev_de5c7021c2b…</code></td>
    </tr>
    <tr>
      <td>运行链路</td>
      <td><code class="language-plaintext highlighter-rouge">ev_640dd028bb6…</code>、<code class="language-plaintext highlighter-rouge">ev_41116969ddd…</code>、<code class="language-plaintext highlighter-rouge">ev_264693a6749…</code></td>
    </tr>
    <tr>
      <td>取票响应</td>
      <td><code class="language-plaintext highlighter-rouge">ev_976337e9c98…</code>、<code class="language-plaintext highlighter-rouge">ev_b5584f8d9e6…</code></td>
    </tr>
    <tr>
      <td>无缓存 / 无兑换</td>
      <td><code class="language-plaintext highlighter-rouge">ev_8398c877a2e…</code>、<code class="language-plaintext highlighter-rouge">ev_11a24d6557c…</code></td>
    </tr>
    <tr>
      <td>JWT 寿命对照</td>
      <td><code class="language-plaintext highlighter-rouge">ev_7d39d791cf4…</code>、<code class="language-plaintext highlighter-rouge">ev_2caa4a6f169…</code></td>
    </tr>
  </tbody>
</table>

<hr />

<h2 id="十一遗留与下一步">十一、遗留与下一步</h2>

<ol>
  <li><strong>寿命/一次性</strong>：需要自有租户 appid 做少量兑换测试（A 立刻兑换、B 延迟兑换、二分收敛），或查厂商文档。</li>
  <li><strong><code class="language-plaintext highlighter-rouge">getCurrLoginStatus</code> 字段集</strong>：继续静态追 <code class="language-plaintext highlighter-rouge">method://pedestal</code> 到原生实现。</li>
  <li><strong>自签 CA 是否加载</strong>：运行时观察 <code class="language-plaintext highlighter-rouge">resources\bin\im\certificate</code> 是否被读取。</li>
  <li><strong>建议的自查</strong>：本文提到的日志文件位于
   <code class="language-plaintext highlighter-rouge">%APPDATA%\WeLink\log\&lt;日期&gt;\business\aioBrowser_ui.log</code>，其中含明文凭据。
   如需分享日志，请先删除 <code class="language-plaintext highlighter-rouge">dealWithRequestResult: code=</code> 之后的内容。</li>
</ol>

<hr />

<p><em>本文所有凭据仅记录长度与形状（96 位大写十六进制），不含任何具体值。</em>
````</p>]]></content><author><name>victoirex</name></author><summary type="html"><![CDATA[WeLink HWH5.getAuthCode 调查总结]]></summary></entry><entry><title type="html">Hello, world!</title><link href="https://extrisha.github.io/2026/11/05/hello-world-1/" rel="alternate" type="text/html" title="Hello, world!" /><published>2026-11-05T23:34:00+08:00</published><updated>2026-11-05T23:34:00+08:00</updated><id>https://extrisha.github.io/2026/11/05/hello-world-1</id><content type="html" xml:base="https://extrisha.github.io/2026/11/05/hello-world-1/"><![CDATA[<p>在想要不要记点东西呢？所以就这样做了。</p>

<p>至于现在要写点什么，还没想好。</p>

<p>总之，这里会写点更real-life的内容吧。</p>

<p>AI真是太方便了，随便讲两句就把东西都搭完了。当然还要感谢开发各种妙妙小工具的前辈们。</p>

<p>这个学期有十三节课要上，我真是魔了。大学物理要怎么办呢？根本听不懂呢。</p>

<p>希望能真的做点什么吧。等我毕业的那天，我会在想什么呢？</p>

<p>话说蓝桥杯开了，虽然课很多、除了课之外的事也很多，不过要不要试一下呢？</p>

<p>哦，还要继续更新我的理堂。</p>

<p>天哪。<img src="/assets/images/BG.jpg" alt="" title="DJKurara - Goodbye" /></p>]]></content><author><name>victoirex</name></author><summary type="html"><![CDATA[在想要不要记点东西呢？所以就这样做了。]]></summary></entry></feed>