Files
hello_js_reverse_skill/tools/cdp_shot.js
T
yml2213 c55f833c66 feat(诊断): 用真机复现解出 1ms 成功会话的 collect 明文 —— 归因改写为「cd 槽位序按会话随机」
结论 (已知 #29~#32, 推翻旧 #25/#27 与"collect 逐字节同构"这条否定实验):
  * 同一个 tdc.js URL 每次请求返回不同构建 (4/4 md5 + XTEA 密钥全不同)
  * 同会话同时抓 tdc.js + verify -> 解密出真机 collect 明文 (784B/38 槽, 可打印率 .991)
  * 5 份同日样本 (真机 cap2 / 签到成功-1 / 点选 / login_checkin / 仓库模板) 全部 38 槽、
    同一批取值、同一个 sd, 但槽位序 5/5 互不相同
  * 仓库在用的模板槽位序 == 签到成功-1 那一次; generate_collect_success() 只回填
    轨迹/时间戳/entry_url, 槽位序仍是那一次的

=> 头号可证伪假设 H-LAYOUT: 服务端按"本次会话构建"的槽位表解释 cd, 用别的会话的槽位序
   会被读成自相矛盾的环境 -> 12 (答案错理应是 50/9)。这也解释了为何换 IP / 换遥测后端 /
   换传输指纹 / 换 cookie / 长静默全都无效 —— 它们都不动槽位序。

新增:
  * scripts/analyze_collect_layout.py —— collect 槽位序对比 (复现 #31)
  * tcaptcha/slider_solver.py + test —— 滑块缺口求解 (ZNCC, 真机首轮命中 ret=0)
  * tcaptcha/icon_click_solver.py + test —— 图文点选形状模板求解
  * scripts/bridge_1ms_captcha.py —— 真机桥接三模式 (slider/icon/text) + --probe 题型侦察
  * tools/cdp_eval.js / cdp_click.js / cdp_shot.js / cdp_net_capture.js / cdp_capture.js
  * selftest 纳入 icon_click / slider 两个套件

账本: §一 修正 #25/#27、新增 #29~#32; §三 标注"collect 逐字节同构"否定实验有缺陷;
      §五 重写 12 的归因与下一步 (决定性实验 A + 取槽位表两条路)
2026-10-11 23:59:42 +08:00

78 lines
3.1 KiB
JavaScript

#!/usr/bin/env node
/**
* cdp_shot.js —— 用 CDP 对**已经在跑的** Chrome 某个标签页截图存成 PNG。
* 零依赖 (Node >= 22 内置 WebSocket/fetch)。
*
* 用法:
* node tools/cdp_shot.js --match drag_ele --out /tmp/a.png # 整页
* node tools/cdp_shot.js --match drag_ele --out /tmp/a.png --clip 10,68,340,243
* node tools/cdp_shot.js --list
*
* 选项:
* --port N 调试端口 (默认 9222)
* --match SUBSTR 选 url 含该子串的 page/iframe 标签页 (默认第一个)
* --out PATH 输出 PNG 路径 (默认 /tmp/cdp_shot.png)
* --clip x,y,w,h 只截该区域 (CSS px, 相对该标签页视口)
* --scale N 设备像素比 (默认 1)
*/
const fs = require('fs');
function arg(name, def) {
const i = process.argv.indexOf('--' + name);
if (i < 0) return def;
const v = process.argv[i + 1];
return (v === undefined || v.startsWith('--')) ? true : v;
}
class Cdp {
constructor(ws) { this.ws = ws; this.id = 0; this.waits = new Map(); }
static async connect(url) {
const ws = new WebSocket(url);
await new Promise((res, rej) => { ws.onopen = res; ws.onerror = rej; });
const c = new Cdp(ws);
ws.onmessage = ev => {
const m = JSON.parse(ev.data);
if (m.id && c.waits.has(m.id)) {
const { res, rej } = c.waits.get(m.id);
c.waits.delete(m.id);
m.error ? rej(new Error(JSON.stringify(m.error))) : res(m.result);
}
};
return c;
}
send(method, params = {}) {
const id = ++this.id;
this.ws.send(JSON.stringify({ id, method, params }));
return new Promise((res, rej) => this.waits.set(id, { res, rej }));
}
close() { try { this.ws.close(); } catch (e) {} }
}
(async () => {
const port = parseInt(arg('port', '9222'), 10);
if (arg('list', false)) {
const t = await (await fetch(`http://127.0.0.1:${port}/json/list`)).json();
for (const x of t) console.log(`${x.type}\t${(x.url || '').slice(0, 120)}\t${x.id}`);
return;
}
const match = arg('match', null);
const targets = (await (await fetch(`http://127.0.0.1:${port}/json/list`)).json())
.filter(t => t.type === 'page' || t.type === 'iframe');
let target = match ? targets.find(t => (t.url || '').includes(match)) : null;
if (!target) target = targets[0];
if (!target) throw new Error('没有可用标签页');
const cdp = await Cdp.connect(target.webSocketDebuggerUrl);
const params = { format: 'png', captureBeyondViewport: !!arg('clip', false) };
const clipRaw = arg('clip', null);
if (clipRaw) {
const [x, y, w, h] = String(clipRaw).split(',').map(Number);
params.clip = { x, y, width: w, height: h, scale: parseFloat(arg('scale', '1')) };
}
const r = await cdp.send('Page.captureScreenshot', params);
const out = arg('out', '/tmp/cdp_shot.png');
fs.writeFileSync(out, Buffer.from(r.data, 'base64'));
console.log(JSON.stringify({ ok: true, out, target: { url: target.url, id: target.id } }));
cdp.close();
})().catch(e => { console.error(String(e)); process.exit(1); });