claude-leak-check 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/brand.js +1 -1
- package/dist/core/scorer.js +96 -8
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/platforms/darwin.d.ts +13 -2
- package/dist/platforms/darwin.js +159 -34
- package/dist/server/local-server.js +9 -2
- package/dist/types/report.d.ts +3 -1
- package/dist/ui/client-script.js +154 -36
- package/dist/ui/format-terminal.js +7 -1
- package/package.json +1 -1
package/dist/config/brand.js
CHANGED
package/dist/core/scorer.js
CHANGED
|
@@ -382,6 +382,48 @@ export function evaluateAuditScores(input) {
|
|
|
382
382
|
},
|
|
383
383
|
});
|
|
384
384
|
}
|
|
385
|
+
else if (input.browserSync.browserExitIpMasked) {
|
|
386
|
+
m3Findings.push({
|
|
387
|
+
id: "browser-cli-uncompared",
|
|
388
|
+
moduleId: "browser_sync",
|
|
389
|
+
severity: "warn",
|
|
390
|
+
pointsDeducted: 0,
|
|
391
|
+
triggersRedline: false,
|
|
392
|
+
title: {
|
|
393
|
+
zh: `已读取浏览器出口 (${input.browserSync.browserExitIpMasked}),但终端底层探针离线未能完成双端比对`,
|
|
394
|
+
en: `Browser exit detected (${input.browserSync.browserExitIpMasked}), but CLI socket probe was offline`,
|
|
395
|
+
},
|
|
396
|
+
detail: {
|
|
397
|
+
zh: "浏览器可正常出网而终端底层无代理探针失败,通常意味着代理仅在浏览器插件内生效而未开启系统级 TUN。",
|
|
398
|
+
en: "Browser reached echo endpoints while CLI socket probes failed, suggesting proxy only runs inside browser without TUN.",
|
|
399
|
+
},
|
|
400
|
+
remediation: {
|
|
401
|
+
zh: "请开启代理客户端的 TUN 虚拟网卡模式后重新执行检测。",
|
|
402
|
+
en: "Enable TUN virtual adapter mode in your proxy client and re-run the check.",
|
|
403
|
+
},
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
else {
|
|
407
|
+
m3Findings.push({
|
|
408
|
+
id: "browser-echo-blocked",
|
|
409
|
+
moduleId: "browser_sync",
|
|
410
|
+
severity: "info",
|
|
411
|
+
pointsDeducted: 0,
|
|
412
|
+
triggersRedline: false,
|
|
413
|
+
title: {
|
|
414
|
+
zh: "浏览器跨域回显请求被拦截或不可达(双端同源待确认)",
|
|
415
|
+
en: "Browser outbound IP echo blocked or unreachable (OAuth sync unverified)",
|
|
416
|
+
},
|
|
417
|
+
detail: {
|
|
418
|
+
zh: `当前浏览器 (${input.envSnap.defaultBrowser}) 对多组公共回显接口的请求均未返回出口 IP。常见原因:(1) Brave Shields、uBlock Origin、AdGuard 等隐私防追踪扩展拦截了 127.0.0.1 页面的跨域回显请求;(2) 浏览器内挂载的独立代理扩展(如 SwitchyOmega)指向了未运行端口导致浏览器断网。`,
|
|
419
|
+
en: `All fallback IP echo requests from ${input.envSnap.defaultBrowser} were blocked or failed. Common causes: (1) Brave Shields / uBlock Origin / AdGuard blocking cross-origin probes from 127.0.0.1, or (2) a misconfigured browser proxy extension.`,
|
|
420
|
+
},
|
|
421
|
+
remediation: {
|
|
422
|
+
zh: "可对 127.0.0.1 临时关闭防追踪盾后点击首屏「点此重试」按钮;若浏览器本身无法访问外网,请关闭冲突的浏览器代理扩展以统一走 TUN。",
|
|
423
|
+
en: "Temporarily lower Brave Shields / ad-blocker on 127.0.0.1 and click Retry above, or disable broken browser proxy extensions.",
|
|
424
|
+
},
|
|
425
|
+
});
|
|
426
|
+
}
|
|
385
427
|
if (input.browserSync.webrtcHasDomesticOrMismatchLeak) {
|
|
386
428
|
m3Deduct += 20;
|
|
387
429
|
addRedline({
|
|
@@ -458,7 +500,7 @@ export function evaluateAuditScores(input) {
|
|
|
458
500
|
// =========================================================================
|
|
459
501
|
const m4Findings = [];
|
|
460
502
|
let m4Deduct = 0;
|
|
461
|
-
// 4.1
|
|
503
|
+
// 4.1 全局 CLI 三态审计(Node 脚本驻留风险 / 未核验版本管理器垫片 / 未完成 postinstall 桩文件)
|
|
462
504
|
const npmCli = input.binaries.find((b) => b.kind === "global-cli-npm-node");
|
|
463
505
|
if (npmCli) {
|
|
464
506
|
m4Deduct += 10;
|
|
@@ -473,12 +515,57 @@ export function evaluateAuditScores(input) {
|
|
|
473
515
|
en: `Detected Node.js-interpreted global 'claude' script (${npmCli.displayPath})`,
|
|
474
516
|
},
|
|
475
517
|
detail: {
|
|
476
|
-
zh: "该入口实际驻留进程为
|
|
477
|
-
en: "This entrypoint executes inside the generic
|
|
518
|
+
zh: "该入口实际驻留进程为 'node'(常见于旧版纯 JS 包或未完成原生二进制替换的 fallback 脚本),LuLu / Little Snitch 等防火墙无法通过 Anthropic 签名将其与普通前端 Node 进程区分开。",
|
|
519
|
+
en: "This entrypoint executes inside the generic 'node' runtime rather than Anthropic's signed native binary, preventing signature-based firewall isolation.",
|
|
520
|
+
},
|
|
521
|
+
remediation: {
|
|
522
|
+
zh: "建议升级至包含原生 Mach-O 二进制的新版 @anthropic-ai/claude-code(确保未开启 --ignore-scripts / --omit=optional),或改用官方独立安装器。",
|
|
523
|
+
en: "Upgrade to a modern native-binary release (without --ignore-scripts / --omit=optional) or use Anthropic's standalone installer.",
|
|
524
|
+
},
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
const unverifiedShim = input.binaries.find((b) => b.kind === "global-cli-unverified-shim");
|
|
528
|
+
if (unverifiedShim) {
|
|
529
|
+
m4Deduct += 4;
|
|
530
|
+
m4Findings.push({
|
|
531
|
+
id: "cli-unverified-shim",
|
|
532
|
+
moduleId: "app_footprint",
|
|
533
|
+
severity: "warn",
|
|
534
|
+
pointsDeducted: 4,
|
|
535
|
+
triggersRedline: false,
|
|
536
|
+
title: {
|
|
537
|
+
zh: `全局 claude 为版本管理器垫片或非 Anthropic 签名程序 (${unverifiedShim.displayPath})`,
|
|
538
|
+
en: `Global 'claude' is a version-manager shim or non-Anthropic binary (${unverifiedShim.displayPath})`,
|
|
539
|
+
},
|
|
540
|
+
detail: {
|
|
541
|
+
zh: "该入口并非带 Anthropic 官方签名的原生 Mach-O(典型如 Volta shim、asdf 或 mise 动态垫片),纯静态检查无法确认其底层最终拉起的是官方签名二进制还是 Node 脚本。",
|
|
542
|
+
en: "This entrypoint is a dynamic shim (e.g. Volta / asdf / mise) or non-Anthropic binary, so static inspection cannot verify its underlying runtime signature.",
|
|
543
|
+
},
|
|
544
|
+
remediation: {
|
|
545
|
+
zh: "建议核实垫片实际转发的底层二进制是否带有 com.anthropic.claude-code (Q6L2SF6YDW) 签名,并在防火墙中按签名或实际落地路径锁定。",
|
|
546
|
+
en: "Verify that the underlying binary invoked by your version manager is signed with com.anthropic.claude-code (Q6L2SF6YDW) and locked in your firewall.",
|
|
547
|
+
},
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
const stubCli = input.binaries.find((b) => b.kind === "global-cli-stub");
|
|
551
|
+
if (stubCli) {
|
|
552
|
+
m4Findings.push({
|
|
553
|
+
id: "cli-uninstalled-stub",
|
|
554
|
+
moduleId: "app_footprint",
|
|
555
|
+
severity: "info",
|
|
556
|
+
pointsDeducted: 0,
|
|
557
|
+
triggersRedline: false,
|
|
558
|
+
title: {
|
|
559
|
+
zh: `检测到未完成 postinstall 的全局 claude 占位桩文件 (${stubCli.displayPath})`,
|
|
560
|
+
en: `Detected incomplete postinstall stub for global 'claude' (${stubCli.displayPath})`,
|
|
561
|
+
},
|
|
562
|
+
detail: {
|
|
563
|
+
zh: "该文件为包管理器跳过 postinstall(如 pnpm v10 默认拦截构建脚本或使用了 --ignore-scripts)留下的报错脚本,运行时直接退出,不会发起网络请求。",
|
|
564
|
+
en: "Placeholder error script left when postinstall was skipped (e.g. pnpm v10 build policy or --ignore-scripts); exits immediately without network activity.",
|
|
478
565
|
},
|
|
479
566
|
remediation: {
|
|
480
|
-
zh: "
|
|
481
|
-
en: "
|
|
567
|
+
zh: "如需使用该全局命令,请执行 pnpm approve-builds -g 允许构建脚本拉取原生二进制,或卸载该残缺全局包。",
|
|
568
|
+
en: "Run 'pnpm approve-builds -g' / reinstall without '--ignore-scripts', or remove the unused broken stub.",
|
|
482
569
|
},
|
|
483
570
|
});
|
|
484
571
|
}
|
|
@@ -598,9 +685,10 @@ export function evaluateAuditScores(input) {
|
|
|
598
685
|
});
|
|
599
686
|
}
|
|
600
687
|
}
|
|
601
|
-
// 4.5
|
|
602
|
-
const
|
|
603
|
-
const
|
|
688
|
+
// 4.5 防火墙焊死度检查(排除无法联网的未安装占位桩文件与已单独告警的动态垫片)
|
|
689
|
+
const actionableBins = input.binaries.filter((b) => b.kind !== "global-cli-stub" && b.kind !== "global-cli-unverified-shim");
|
|
690
|
+
const installedCount = actionableBins.length;
|
|
691
|
+
const unprotectedBins = actionableBins.filter((b) => !b.firewallCovered);
|
|
604
692
|
if (installedCount > 0 && unprotectedBins.length > 0 && !input.firewallAudit.littleSnitchDetected) {
|
|
605
693
|
const pts = Math.min(10, input.firewallAudit.bootRaceRisk ? 10 : 7);
|
|
606
694
|
m4Deduct += pts;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { runFullAudit, stripLocalToggleRawFields, type RunAuditConfig } from "./
|
|
|
4
4
|
export { maskIp, sanitizePath, scrubFreeText, parseClashYamlMetadataSafely, } from "./core/privacy.js";
|
|
5
5
|
export { inspectClaudeSettingsAndProxyEnv, type SettingsAndProxyEnvInput, type SettingsAndProxyEnvResult, } from "./core/settings-env-inspector.js";
|
|
6
6
|
export { evaluateAuditScores } from "./core/scorer.js";
|
|
7
|
-
export { classifyAsnOrg, extractListeningLoopbackPortsMac, inspectCliBinaryKind, type CliBinaryInspection, } from "./platforms/darwin.js";
|
|
7
|
+
export { classifyAsnOrg, extractListeningLoopbackPortsMac, inspectCliBinaryKind, verifyAnthropicCodesignOutput, type CliBinaryClassification, type CliBinaryInspection, } from "./platforms/darwin.js";
|
|
8
8
|
export { parseAppleXmlPlist, unarchiveNsKeyedPlist, parseLuluRules, parseLuluRulesJson, hasMacosPfDeadlockPattern, extractLaunchDaemonLabelAndScripts, isLaunchDaemonActive, } from "./platforms/lulu-parser.js";
|
|
9
9
|
export { startLocalReportServer, type LocalServerHandle } from "./server/local-server.js";
|
|
10
10
|
export { renderReportHtml } from "./ui/render-html.js";
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { runFullAudit, stripLocalToggleRawFields } from "./core/engine.js";
|
|
|
4
4
|
export { maskIp, sanitizePath, scrubFreeText, parseClashYamlMetadataSafely, } from "./core/privacy.js";
|
|
5
5
|
export { inspectClaudeSettingsAndProxyEnv, } from "./core/settings-env-inspector.js";
|
|
6
6
|
export { evaluateAuditScores } from "./core/scorer.js";
|
|
7
|
-
export { classifyAsnOrg, extractListeningLoopbackPortsMac, inspectCliBinaryKind, } from "./platforms/darwin.js";
|
|
7
|
+
export { classifyAsnOrg, extractListeningLoopbackPortsMac, inspectCliBinaryKind, verifyAnthropicCodesignOutput, } from "./platforms/darwin.js";
|
|
8
8
|
export { parseAppleXmlPlist, unarchiveNsKeyedPlist, parseLuluRules, parseLuluRulesJson, hasMacosPfDeadlockPattern, extractLaunchDaemonLabelAndScripts, isLaunchDaemonActive, } from "./platforms/lulu-parser.js";
|
|
9
9
|
export { startLocalReportServer } from "./server/local-server.js";
|
|
10
10
|
export { renderReportHtml } from "./ui/render-html.js";
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { ClaudeBinaryItem, DomainProbeResult, DomainTarget, FirewallAudit, ProxyStaticAudit, PublicExitSnapshot } from "../types/report.js";
|
|
2
2
|
import type { AuditOptions, EnvironmentHygieneSnapshot, KillSwitchProbeSnapshot, NetworkStackSnapshot, PlatformAdapter } from "./types.js";
|
|
3
|
+
export declare function verifyAnthropicCodesignOutput(codesignCombinedOutput: string): {
|
|
4
|
+
signedByAnthropic: boolean;
|
|
5
|
+
identifier?: string;
|
|
6
|
+
teamId?: string;
|
|
7
|
+
};
|
|
3
8
|
export declare function classifyAsnOrg(org?: string): "isp" | "hosting" | "education" | "business" | "unknown";
|
|
4
9
|
export declare class DarwinPlatformAdapter implements PlatformAdapter {
|
|
5
10
|
readonly platform: "darwin";
|
|
@@ -20,14 +25,20 @@ export declare class DarwinPlatformAdapter implements PlatformAdapter {
|
|
|
20
25
|
runKillSwitchProbe(): Promise<KillSwitchProbeSnapshot>;
|
|
21
26
|
}
|
|
22
27
|
export declare function extractListeningLoopbackPortsMac(netstatOut: string): number[];
|
|
28
|
+
export type CliBinaryClassification = "node-script" | "native-macho" | "uninstalled-stub" | "unknown-shim";
|
|
23
29
|
export interface CliBinaryInspection {
|
|
30
|
+
classification: CliBinaryClassification;
|
|
24
31
|
isNodeScript: boolean;
|
|
25
32
|
isMachO: boolean;
|
|
26
33
|
viaShellExecWrapper: boolean;
|
|
27
34
|
resolvedBinaryPath: string;
|
|
28
35
|
}
|
|
29
36
|
/**
|
|
30
|
-
* 追踪软链接与包管理器(pnpm / yarn / fnm
|
|
31
|
-
*
|
|
37
|
+
* 追踪软链接与包管理器(pnpm / yarn / fnm / volta / asdf / mise)生成的启动入口,
|
|
38
|
+
* 严谨区分四类落点:
|
|
39
|
+
* - `native-macho`:最终指向原生 Mach-O 二进制(后续再交由 `codesign -dv` stderr 校验是否为 Anthropic 签名)
|
|
40
|
+
* - `node-script`:最终驻留 `node` / `bun` / `deno` 解释器运行 JS 脚本
|
|
41
|
+
* - `uninstalled-stub`:`@anthropic-ai/claude-code` 因跳过 `postinstall` 留下的报错占位桩文件
|
|
42
|
+
* - `unknown-shim`:`asdf` / `mise` 等动态环境垫片或无法静态确认落点的自定义脚本
|
|
32
43
|
*/
|
|
33
44
|
export declare function inspectCliBinaryKind(filePath: string, depth?: number): CliBinaryInspection;
|
package/dist/platforms/darwin.js
CHANGED
|
@@ -22,6 +22,40 @@ async function runCmd(cmd, args, timeoutMs = 2500) {
|
|
|
22
22
|
return "";
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* 合并读取 stdout 与 stderr(macOS 的 `/usr/bin/codesign -dv` 全部签名元数据均输出在 stderr)
|
|
27
|
+
*/
|
|
28
|
+
async function runCmdCombined(cmd, args, timeoutMs = 2500) {
|
|
29
|
+
try {
|
|
30
|
+
const { stdout, stderr } = await execFileAsync(cmd, args, {
|
|
31
|
+
timeout: timeoutMs,
|
|
32
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
33
|
+
env: { ...process.env, LC_ALL: "C" },
|
|
34
|
+
});
|
|
35
|
+
return `${stdout || ""}\n${stderr || ""}`.trim();
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
if (err && typeof err === "object") {
|
|
39
|
+
const rec = err;
|
|
40
|
+
const out = typeof rec.stdout === "string" ? rec.stdout : "";
|
|
41
|
+
const errOut = typeof rec.stderr === "string" ? rec.stderr : "";
|
|
42
|
+
return `${out}\n${errOut}`.trim();
|
|
43
|
+
}
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function verifyAnthropicCodesignOutput(codesignCombinedOutput) {
|
|
48
|
+
if (!codesignCombinedOutput || /not signed at all/i.test(codesignCombinedOutput)) {
|
|
49
|
+
return { signedByAnthropic: false };
|
|
50
|
+
}
|
|
51
|
+
const idMatch = /^Identifier=(\S+)/m.exec(codesignCombinedOutput);
|
|
52
|
+
const teamMatch = /^TeamIdentifier=(\S+)/m.exec(codesignCombinedOutput);
|
|
53
|
+
const identifier = idMatch?.[1];
|
|
54
|
+
const teamId = teamMatch?.[1];
|
|
55
|
+
const signedByAnthropic = teamId === "Q6L2SF6YDW" ||
|
|
56
|
+
Boolean(identifier && /^com\.anthropic\.claude(?:-code|fordesktop)?(?:\.|$)/i.test(identifier));
|
|
57
|
+
return { signedByAnthropic, identifier, teamId };
|
|
58
|
+
}
|
|
25
59
|
async function runCurlProbe(args, timeoutSec = 3.2) {
|
|
26
60
|
const start = Date.now();
|
|
27
61
|
try {
|
|
@@ -565,6 +599,9 @@ export class DarwinPlatformAdapter {
|
|
|
565
599
|
"/usr/local/bin/claude",
|
|
566
600
|
join(home, ".bun/bin/claude"),
|
|
567
601
|
join(home, "Library/pnpm/claude"),
|
|
602
|
+
join(home, ".volta/bin/claude"),
|
|
603
|
+
join(home, ".asdf/shims/claude"),
|
|
604
|
+
join(home, ".local/share/mise/shims/claude"),
|
|
568
605
|
]) {
|
|
569
606
|
if (existsSync(extra))
|
|
570
607
|
globalCandidates.add(extra);
|
|
@@ -574,11 +611,12 @@ export class DarwinPlatformAdapter {
|
|
|
574
611
|
if (!existsSync(cliPath))
|
|
575
612
|
continue;
|
|
576
613
|
const binType = inspectCliBinaryKind(cliPath);
|
|
577
|
-
const dedupeKey = binType.resolvedBinaryPath || cliPath
|
|
614
|
+
const dedupeKey = `${binType.classification}:${binType.resolvedBinaryPath || cliPath}`;
|
|
578
615
|
if (seenResolvedCliTargets.has(dedupeKey))
|
|
579
616
|
continue;
|
|
580
617
|
seenResolvedCliTargets.add(dedupeKey);
|
|
581
|
-
if (binType.
|
|
618
|
+
if (binType.classification === "node-script") {
|
|
619
|
+
// 分支 A:确认为驻留 node / bun / deno 解释器的 JS 脚本
|
|
582
620
|
binaries.push({
|
|
583
621
|
id: `global-npm-${cliPath}`,
|
|
584
622
|
name: "全局终端 claude (Node.js 脚本运行时)",
|
|
@@ -594,33 +632,90 @@ export class DarwinPlatformAdapter {
|
|
|
594
632
|
},
|
|
595
633
|
});
|
|
596
634
|
}
|
|
597
|
-
else {
|
|
598
|
-
|
|
599
|
-
const codesignOut = await runCmd("/usr/bin/codesign", ["-dv", signCheckTarget], 1500);
|
|
600
|
-
const signed = /anthropic|Q6L2SF6YDW/i.test(codesignOut) || binType.isMachO;
|
|
601
|
-
const viaPkgManager = /node_modules|pnpm/i.test(signCheckTarget) || binType.viaShellExecWrapper;
|
|
602
|
-
const covered = luluActive && luluSummary.coversAnthropicSigningId;
|
|
635
|
+
else if (binType.classification === "uninstalled-stub") {
|
|
636
|
+
// 分支 C1:pnpm v10 默认拦截 postinstall 或 --ignore-scripts 留下的报错占位桩文件
|
|
603
637
|
binaries.push({
|
|
604
|
-
id: `global-
|
|
605
|
-
name:
|
|
606
|
-
? "全局终端 claude (npm/pnpm 分发原生二进制)"
|
|
607
|
-
: "全局终端 claude (官方原生二进制)",
|
|
638
|
+
id: `global-stub-${cliPath}`,
|
|
639
|
+
name: "全局终端 claude (未完成 postinstall 占位脚本)",
|
|
608
640
|
displayPath: sanitizePath(cliPath),
|
|
609
|
-
kind: "global-cli-
|
|
641
|
+
kind: "global-cli-stub",
|
|
610
642
|
exists: true,
|
|
611
|
-
signedByAnthropic:
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
643
|
+
signedByAnthropic: false,
|
|
644
|
+
firewallCovered: false,
|
|
645
|
+
riskLevel: "warn",
|
|
646
|
+
note: {
|
|
647
|
+
zh: "检测到 `claude native binary not installed` 报错桩文件(常见于 pnpm v10 拦截 postinstall 或使用了 --ignore-scripts / --omit=optional),当前无法运行,需执行 postinstall 拉取原生二进制。",
|
|
648
|
+
en: "Placeholder stub ('claude native binary not installed'); postinstall was skipped (e.g. pnpm v10 build policy or --ignore-scripts).",
|
|
649
|
+
},
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
else if (binType.classification === "native-macho") {
|
|
653
|
+
// 读取 codesign -dv 合并输出 (stderr) 严格验证是否确实携带 Anthropic 官方签名(排除 volta-shim 等第三方二进制垫片!)
|
|
654
|
+
const signCheckTarget = binType.resolvedBinaryPath || cliPath;
|
|
655
|
+
const codesignOut = await runCmdCombined("/usr/bin/codesign", ["-dv", signCheckTarget], 1500);
|
|
656
|
+
const signVerify = verifyAnthropicCodesignOutput(codesignOut);
|
|
657
|
+
if (signVerify.signedByAnthropic) {
|
|
658
|
+
// 分支 B:确认为带 Anthropic 官方签名的原生 Mach-O 二进制
|
|
659
|
+
const viaPkgManager = /node_modules|pnpm/i.test(signCheckTarget) || binType.viaShellExecWrapper;
|
|
660
|
+
const covered = luluActive && luluSummary.coversAnthropicSigningId;
|
|
661
|
+
binaries.push({
|
|
662
|
+
id: `global-native-${cliPath}`,
|
|
663
|
+
name: viaPkgManager
|
|
664
|
+
? "全局终端 claude (npm/pnpm 分发原生二进制)"
|
|
665
|
+
: "全局终端 claude (官方原生二进制)",
|
|
666
|
+
displayPath: sanitizePath(cliPath),
|
|
667
|
+
kind: "global-cli-native",
|
|
668
|
+
exists: true,
|
|
669
|
+
signedByAnthropic: true,
|
|
670
|
+
teamId: signVerify.teamId,
|
|
671
|
+
bundleOrSigningId: signVerify.identifier || "com.anthropic.claude-code",
|
|
672
|
+
firewallCovered: covered,
|
|
673
|
+
riskLevel: covered ? "pass" : "warn",
|
|
674
|
+
note: covered
|
|
675
|
+
? {
|
|
676
|
+
zh: "已通过 codesign 确认为 Anthropic 官方签名 Mach-O 二进制,且已受防火墙签名规则锁定",
|
|
677
|
+
en: "Verified Anthropic-signed Mach-O binary covered by firewall signing rule",
|
|
678
|
+
}
|
|
679
|
+
: {
|
|
680
|
+
zh: "已通过 codesign 确认为 Anthropic 官方签名 Mach-O 二进制(无 node 驻留),可在防火墙中按签名 com.anthropic.claude-code 单独锁定",
|
|
681
|
+
en: "Verified Anthropic-signed Mach-O binary (no Node runtime); lock via signing ID com.anthropic.claude-code in firewall",
|
|
682
|
+
},
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
else {
|
|
686
|
+
// 分支 C2:虽然是 Mach-O 二进制,但并非 Anthropic 签名(典型如 ~/.volta/bin/claude 指向的 volta-shim)
|
|
687
|
+
binaries.push({
|
|
688
|
+
id: `global-shim-macho-${cliPath}`,
|
|
689
|
+
name: "全局终端 claude (版本管理器二进制垫片 / 非官方签名)",
|
|
690
|
+
displayPath: sanitizePath(cliPath),
|
|
691
|
+
kind: "global-cli-unverified-shim",
|
|
692
|
+
exists: true,
|
|
693
|
+
signedByAnthropic: false,
|
|
694
|
+
bundleOrSigningId: signVerify.identifier,
|
|
695
|
+
firewallCovered: false,
|
|
696
|
+
riskLevel: "warn",
|
|
697
|
+
note: {
|
|
698
|
+
zh: `该入口为非 Anthropic 签名的二进制垫片(如 Volta shim${signVerify.identifier ? `: ${signVerify.identifier}` : ""}),无法静态确认其转发的目标程序是原生签名版还是旧版 node 脚本,请核实底层实际工具链路径与签名。`,
|
|
699
|
+
en: "Non-Anthropic binary shim (e.g. Volta shim); cannot statically confirm whether the delegated binary is native-signed or Node-based.",
|
|
623
700
|
},
|
|
701
|
+
});
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
else {
|
|
705
|
+
// 分支 C3:asdf / mise 等动态 Shell 垫片或无法静态追踪 exec 落点的包装脚本
|
|
706
|
+
binaries.push({
|
|
707
|
+
id: `global-shim-script-${cliPath}`,
|
|
708
|
+
name: "全局终端 claude (动态环境垫片脚本 / 待核验)",
|
|
709
|
+
displayPath: sanitizePath(cliPath),
|
|
710
|
+
kind: "global-cli-unverified-shim",
|
|
711
|
+
exists: true,
|
|
712
|
+
signedByAnthropic: false,
|
|
713
|
+
firewallCovered: false,
|
|
714
|
+
riskLevel: "warn",
|
|
715
|
+
note: {
|
|
716
|
+
zh: "该入口为动态版本管理器垫片(如 asdf / mise shim)或自定义脚本,无法静态解析最终二进制签名,请执行 `claude --version` 并核实实际落地文件是否携带 com.anthropic.claude-code 签名。",
|
|
717
|
+
en: "Dynamic version-manager shim (e.g. asdf / mise); cannot statically resolve underlying binary code signature.",
|
|
718
|
+
},
|
|
624
719
|
});
|
|
625
720
|
}
|
|
626
721
|
}
|
|
@@ -677,10 +772,11 @@ export class DarwinPlatformAdapter {
|
|
|
677
772
|
const installedCliBins = binaries.filter((b) => b.kind === "desktop-bundled-cli" ||
|
|
678
773
|
b.kind === "global-cli-native" ||
|
|
679
774
|
b.kind === "global-cli-npm-node" ||
|
|
775
|
+
b.kind === "global-cli-unverified-shim" ||
|
|
680
776
|
b.kind === "ide-extension-cli");
|
|
681
777
|
const claudeCliLocked = installedCliBins.length > 0
|
|
682
778
|
? installedCliBins.every((b) => b.firewallCovered) &&
|
|
683
|
-
!installedCliBins.some((b) => b.kind === "global-cli-npm-node")
|
|
779
|
+
!installedCliBins.some((b) => b.kind === "global-cli-npm-node" || b.kind === "global-cli-unverified-shim")
|
|
684
780
|
: claudeAppFullyLocked;
|
|
685
781
|
return {
|
|
686
782
|
binaries,
|
|
@@ -967,15 +1063,20 @@ function hasMachOMagic(filePath) {
|
|
|
967
1063
|
}
|
|
968
1064
|
}
|
|
969
1065
|
/**
|
|
970
|
-
* 追踪软链接与包管理器(pnpm / yarn / fnm
|
|
971
|
-
*
|
|
1066
|
+
* 追踪软链接与包管理器(pnpm / yarn / fnm / volta / asdf / mise)生成的启动入口,
|
|
1067
|
+
* 严谨区分四类落点:
|
|
1068
|
+
* - `native-macho`:最终指向原生 Mach-O 二进制(后续再交由 `codesign -dv` stderr 校验是否为 Anthropic 签名)
|
|
1069
|
+
* - `node-script`:最终驻留 `node` / `bun` / `deno` 解释器运行 JS 脚本
|
|
1070
|
+
* - `uninstalled-stub`:`@anthropic-ai/claude-code` 因跳过 `postinstall` 留下的报错占位桩文件
|
|
1071
|
+
* - `unknown-shim`:`asdf` / `mise` 等动态环境垫片或无法静态确认落点的自定义脚本
|
|
972
1072
|
*/
|
|
973
1073
|
export function inspectCliBinaryKind(filePath, depth = 0) {
|
|
974
1074
|
if (depth > 4) {
|
|
975
1075
|
return {
|
|
1076
|
+
classification: "unknown-shim",
|
|
976
1077
|
isNodeScript: false,
|
|
977
1078
|
isMachO: false,
|
|
978
|
-
viaShellExecWrapper:
|
|
1079
|
+
viaShellExecWrapper: depth > 0,
|
|
979
1080
|
resolvedBinaryPath: filePath,
|
|
980
1081
|
};
|
|
981
1082
|
}
|
|
@@ -993,33 +1094,45 @@ export function inspectCliBinaryKind(filePath, depth = 0) {
|
|
|
993
1094
|
}
|
|
994
1095
|
}
|
|
995
1096
|
try {
|
|
996
|
-
// 1. 先直接读取文件头判断是否为原生 Mach-O
|
|
1097
|
+
// 1. 先直接读取文件头判断是否为原生 Mach-O 可执行文件(含官方二进制或 volta-shim 等二进制垫片,由上层结合 codesign 区分)
|
|
997
1098
|
if (hasMachOMagic(realTarget)) {
|
|
998
1099
|
return {
|
|
1100
|
+
classification: "native-macho",
|
|
999
1101
|
isNodeScript: false,
|
|
1000
1102
|
isMachO: true,
|
|
1001
1103
|
viaShellExecWrapper: depth > 0,
|
|
1002
1104
|
resolvedBinaryPath: realTarget,
|
|
1003
1105
|
};
|
|
1004
1106
|
}
|
|
1005
|
-
// 2. 非二进制文件:读取前 4KB
|
|
1107
|
+
// 2. 非二进制文件:读取前 4KB 检查报错桩文件、Shebang 与 Shell exec 链路
|
|
1006
1108
|
const fd = openSync(realTarget, "r");
|
|
1007
1109
|
const buf = Buffer.alloc(4096);
|
|
1008
1110
|
const bytesRead = readSync(fd, buf, 0, 4096, 0);
|
|
1009
1111
|
closeSync(fd);
|
|
1010
1112
|
const text = buf.subarray(0, bytesRead).toString("utf8");
|
|
1011
1113
|
const firstLine = (text.split(/\r?\n/, 1)[0] || "").trim();
|
|
1012
|
-
// 2a.
|
|
1114
|
+
// 2a. `@anthropic-ai/claude-code` 跳过 postinstall(如 pnpm v10 默认拦截或 --ignore-scripts)时残留的无 #! 9 行报错桩脚本
|
|
1115
|
+
if (/claude native binary not installed/i.test(text)) {
|
|
1116
|
+
return {
|
|
1117
|
+
classification: "uninstalled-stub",
|
|
1118
|
+
isNodeScript: false,
|
|
1119
|
+
isMachO: false,
|
|
1120
|
+
viaShellExecWrapper: depth > 0,
|
|
1121
|
+
resolvedBinaryPath: realTarget,
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
// 2b. 直接由 node / bun / deno 解释执行的 JS 脚本(如旧版 cli.js 或 cli-wrapper.cjs)
|
|
1013
1125
|
if ((firstLine.startsWith("#!") && /\b(node|bun|deno)\b/i.test(firstLine)) ||
|
|
1014
1126
|
/\.(c?js|mjs)$/i.test(realTarget)) {
|
|
1015
1127
|
return {
|
|
1128
|
+
classification: "node-script",
|
|
1016
1129
|
isNodeScript: true,
|
|
1017
1130
|
isMachO: false,
|
|
1018
1131
|
viaShellExecWrapper: depth > 0,
|
|
1019
1132
|
resolvedBinaryPath: realTarget,
|
|
1020
1133
|
};
|
|
1021
1134
|
}
|
|
1022
|
-
//
|
|
1135
|
+
// 2c. POSIX Shell 包装脚本(如 pnpm cmd-shim 或 asdf / mise 动态垫片)
|
|
1023
1136
|
if (firstLine.startsWith("#!") && /\b(sh|bash|zsh|dash)\b/i.test(firstLine)) {
|
|
1024
1137
|
const baseDir = dirname(realTarget);
|
|
1025
1138
|
const lines = text
|
|
@@ -1033,13 +1146,24 @@ export function inspectCliBinaryKind(filePath, depth = 0) {
|
|
|
1033
1146
|
if (/^exec\s+(?:["']?[^"'\s]*\/)?(?:node|bun|deno)(?:\.exe)?["']?\s/i.test(line) ||
|
|
1034
1147
|
/\.(c?js|mjs)["']?(?:\s|$)/i.test(line)) {
|
|
1035
1148
|
return {
|
|
1149
|
+
classification: "node-script",
|
|
1036
1150
|
isNodeScript: true,
|
|
1037
1151
|
isMachO: false,
|
|
1038
1152
|
viaShellExecWrapper: true,
|
|
1039
1153
|
resolvedBinaryPath: realTarget,
|
|
1040
1154
|
};
|
|
1041
1155
|
}
|
|
1042
|
-
//
|
|
1156
|
+
// 若 exec 转发给 asdf / mise / rtx / volta / nodenv 等版本管理器分发器,无法静态确认最终二进制签名
|
|
1157
|
+
if (/^exec\s+(?:["']?[^"'\s]*\/)?(?:asdf|mise|rtx|volta|volta-shim|nodenv|anyenv)["']?(?:\s|$)/i.test(line)) {
|
|
1158
|
+
return {
|
|
1159
|
+
classification: "unknown-shim",
|
|
1160
|
+
isNodeScript: false,
|
|
1161
|
+
isMachO: false,
|
|
1162
|
+
viaShellExecWrapper: true,
|
|
1163
|
+
resolvedBinaryPath: realTarget,
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
// 提取 exec 指向的具体目标文件路径(替换 $basedir / ${basedir})
|
|
1043
1167
|
const quotedTarget = /^exec\s+"([^"]+)"/.exec(line) || /^exec\s+'([^']+)'/.exec(line);
|
|
1044
1168
|
const bareTarget = !quotedTarget ? /^exec\s+(\S+)/.exec(line) : null;
|
|
1045
1169
|
const rawExecExpr = quotedTarget?.[1] || bareTarget?.[1];
|
|
@@ -1060,6 +1184,7 @@ export function inspectCliBinaryKind(filePath, depth = 0) {
|
|
|
1060
1184
|
// ignore
|
|
1061
1185
|
}
|
|
1062
1186
|
return {
|
|
1187
|
+
classification: "unknown-shim",
|
|
1063
1188
|
isNodeScript: false,
|
|
1064
1189
|
isMachO: false,
|
|
1065
1190
|
viaShellExecWrapper: depth > 0,
|
|
@@ -137,10 +137,12 @@ export async function startLocalReportServer(initialReport, adapter, sessionSalt
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
currentReport.browserSync = {
|
|
140
|
-
completed:
|
|
140
|
+
completed: true,
|
|
141
|
+
probeBlockedOrFailed: !rawBrowserIp,
|
|
142
|
+
probeSource: typeof body.probeSource === "string" ? body.probeSource.trim().slice(0, 40) : undefined,
|
|
141
143
|
browserExitIpMasked: rawBrowserIp ? maskIp(rawBrowserIp) : undefined,
|
|
142
144
|
browserExitIpHash,
|
|
143
|
-
browserCountryCode: browserCountry,
|
|
145
|
+
browserCountryCode: browserCountry || undefined,
|
|
144
146
|
matchesCliExit,
|
|
145
147
|
webrtcTested: Boolean(body.webrtcTested),
|
|
146
148
|
webrtcPublicIpsMasked: publicWebrtcIps,
|
|
@@ -263,6 +265,11 @@ export async function startLocalReportServer(initialReport, adapter, sessionSalt
|
|
|
263
265
|
Boolean(exits.primaryExit?.isSupportedRegion);
|
|
264
266
|
if (restoredOk) {
|
|
265
267
|
currentReport.primaryExit = exits.primaryExit;
|
|
268
|
+
currentReport.cliExitIpHash = exits.cliExitIpHash;
|
|
269
|
+
if (currentReport.browserSync.browserExitIpHash && exits.cliExitIpHash) {
|
|
270
|
+
currentReport.browserSync.matchesCliExit =
|
|
271
|
+
currentReport.browserSync.browserExitIpHash === exits.cliExitIpHash;
|
|
272
|
+
}
|
|
266
273
|
currentReport.killSwitchDrill.proxyRestoredVerified = true;
|
|
267
274
|
cachedEnvSnap = await adapter.inspectEnvironmentHygiene(cachedNetSnap, currentReport.proxyAudit);
|
|
268
275
|
recomputeScores();
|
package/dist/types/report.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export interface ClaudeBinaryItem {
|
|
|
51
51
|
id: string;
|
|
52
52
|
name: string;
|
|
53
53
|
displayPath: string;
|
|
54
|
-
kind: "desktop-main" | "desktop-helper" | "desktop-updater" | "desktop-cowork-vm" | "desktop-bundled-cli" | "global-cli-native" | "global-cli-npm-node" | "ide-extension-cli";
|
|
54
|
+
kind: "desktop-main" | "desktop-helper" | "desktop-updater" | "desktop-cowork-vm" | "desktop-bundled-cli" | "global-cli-native" | "global-cli-npm-node" | "global-cli-unverified-shim" | "global-cli-stub" | "ide-extension-cli";
|
|
55
55
|
exists: boolean;
|
|
56
56
|
signedByAnthropic: boolean;
|
|
57
57
|
teamId?: string;
|
|
@@ -117,6 +117,8 @@ export interface ModuleScore {
|
|
|
117
117
|
}
|
|
118
118
|
export interface BrowserRealtimeSync {
|
|
119
119
|
completed: boolean;
|
|
120
|
+
probeBlockedOrFailed?: boolean;
|
|
121
|
+
probeSource?: string;
|
|
120
122
|
browserExitIpMasked?: string;
|
|
121
123
|
browserExitIpHash?: string;
|
|
122
124
|
browserCountryCode?: string;
|
package/dist/ui/client-script.js
CHANGED
|
@@ -9,6 +9,7 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
9
9
|
masked: true,
|
|
10
10
|
domainFilter: "all",
|
|
11
11
|
liveTunActive: null,
|
|
12
|
+
syncProbing: false,
|
|
12
13
|
drillLoading: false,
|
|
13
14
|
restoreLoading: false,
|
|
14
15
|
posterRatio: "16:9"
|
|
@@ -42,6 +43,9 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
42
43
|
syncMismatch: "双 IP 横跳高危 ✕",
|
|
43
44
|
syncChecking: "正在本地比对...",
|
|
44
45
|
syncStaticOnly: "静态模式",
|
|
46
|
+
syncBlockedRetry: "回显被拦截 · 点此重试 ↻",
|
|
47
|
+
syncBlockedStatic: "回显被浏览器拦截",
|
|
48
|
+
syncCliOffline: "浏览器 {IP} (CLI 离线)",
|
|
45
49
|
webrtcClean: "0 公网泄漏 ✓",
|
|
46
50
|
webrtcLeak: "暴露公网 IP ✕",
|
|
47
51
|
drillTitle: "离线交互式「断网防漏演练」",
|
|
@@ -80,6 +84,8 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
80
84
|
fwLocked: "防火墙已焊死 ✓",
|
|
81
85
|
fwUnlocked: "未锁定 / 可直连",
|
|
82
86
|
npmDanger: "npm node 进程盲区 ✕",
|
|
87
|
+
shimWarn: "垫片待核验 !",
|
|
88
|
+
stubWarn: "未完成安装 (桩文件)",
|
|
83
89
|
modalTitle: "导出脱敏体检卡",
|
|
84
90
|
modalSub: "真实 IP、系统用户名与节点信息已在画布层自动打码(如 198.51.*.*),可直接截图或保存图片分享。",
|
|
85
91
|
ratio169: "16:9 横版",
|
|
@@ -92,7 +98,9 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
92
98
|
toastCopiedImg: "已将高清脱敏海报复制到剪贴板!可直接粘贴发送",
|
|
93
99
|
toastCopiedText: "已复制分享配文到剪贴板!",
|
|
94
100
|
toastRestoreOk: "绿灯复检通过!TUN 与安全海外出口已恢复,可以放心使用 Claude。",
|
|
95
|
-
toastRestoreFail: "尚未检测到 TUN 与受支持海外出口恢复,请确认代理已开启并连接成功!"
|
|
101
|
+
toastRestoreFail: "尚未检测到 TUN 与受支持海外出口恢复,请确认代理已开启并连接成功!",
|
|
102
|
+
toastSyncRetryOk: "已完成浏览器出口复检!",
|
|
103
|
+
toastSyncRetryBlocked: "浏览器仍拦截跨域回显请求,请检查 Brave Shields / 去广告扩展或浏览器代理插件。"
|
|
96
104
|
},
|
|
97
105
|
en: {
|
|
98
106
|
eyebrow: "100% Read-Only Local Audit · Zero Credential Access · Zero System Modification",
|
|
@@ -121,6 +129,9 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
121
129
|
syncMismatch: "Dual-IP Hop Detected ✕",
|
|
122
130
|
syncChecking: "Comparing locally...",
|
|
123
131
|
syncStaticOnly: "Static Snapshot",
|
|
132
|
+
syncBlockedRetry: "Echo Blocked · Retry ↻",
|
|
133
|
+
syncBlockedStatic: "Blocked by Browser Shield",
|
|
134
|
+
syncCliOffline: "Browser {IP} (CLI Offline)",
|
|
124
135
|
webrtcClean: "0 Public Leak ✓",
|
|
125
136
|
webrtcLeak: "Public IP Leaked ✕",
|
|
126
137
|
drillTitle: "Interactive Offline Kill-Switch Drill",
|
|
@@ -159,6 +170,8 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
159
170
|
fwLocked: "Firewall Locked ✓",
|
|
160
171
|
fwUnlocked: "Unprotected",
|
|
161
172
|
npmDanger: "npm 'node' Blindspot ✕",
|
|
173
|
+
shimWarn: "Unverified Shim !",
|
|
174
|
+
stubWarn: "Incomplete Stub",
|
|
162
175
|
modalTitle: "Export Redacted Diagnostic Card",
|
|
163
176
|
modalSub: "Real IPs, usernames, and node names are strictly masked on canvas (e.g. 198.51.*.*), ready for X, Reddit, or Discord.",
|
|
164
177
|
ratio169: "16:9 Landscape (X / GitHub)",
|
|
@@ -171,7 +184,9 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
171
184
|
toastCopiedImg: "Copied Retina PNG card to clipboard!",
|
|
172
185
|
toastCopiedText: "Copied share caption to clipboard!",
|
|
173
186
|
toastRestoreOk: "Verified! TUN and safe overseas exit are back online.",
|
|
174
|
-
toastRestoreFail: "TUN or safe overseas exit is not yet active. Check your proxy client!"
|
|
187
|
+
toastRestoreFail: "TUN or safe overseas exit is not yet active. Check your proxy client!",
|
|
188
|
+
toastSyncRetryOk: "Browser OAuth exit check updated!",
|
|
189
|
+
toastSyncRetryBlocked: "Echo requests still blocked by browser shield/ad-blocker or broken proxy plugin."
|
|
175
190
|
}
|
|
176
191
|
};
|
|
177
192
|
|
|
@@ -294,13 +309,25 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
294
309
|
: "Offline / Unreachable";
|
|
295
310
|
|
|
296
311
|
var syncBadgeHtml = "";
|
|
297
|
-
if (
|
|
312
|
+
if (state.syncProbing) {
|
|
313
|
+
syncBadgeHtml = '<span class="status-badge st-info">' + esc(t("syncChecking")) + "</span>";
|
|
314
|
+
} else if (r.browserSync && r.browserSync.completed) {
|
|
298
315
|
if (r.browserSync.matchesCliExit === true) {
|
|
299
316
|
syncBadgeHtml = '<span class="status-badge st-pass">' + esc(t("syncMatched")) + "</span>";
|
|
300
317
|
} else if (r.browserSync.matchesCliExit === false) {
|
|
301
318
|
syncBadgeHtml = '<span class="status-badge st-crit">' + esc(t("syncMismatch")) + "</span>";
|
|
319
|
+
} else if (r.browserSync.browserExitIpMasked) {
|
|
320
|
+
syncBadgeHtml =
|
|
321
|
+
'<span class="status-badge st-warn">' +
|
|
322
|
+
esc(t("syncCliOffline").replace("{IP}", r.browserSync.browserExitIpMasked)) +
|
|
323
|
+
"</span>";
|
|
324
|
+
} else if (state.token) {
|
|
325
|
+
syncBadgeHtml =
|
|
326
|
+
'<button type="button" id="retrySyncBtn" class="status-badge st-warn" style="cursor:pointer;border:1px solid rgba(245,158,11,0.38);font-family:inherit">' +
|
|
327
|
+
esc(t("syncBlockedRetry")) +
|
|
328
|
+
"</button>";
|
|
302
329
|
} else {
|
|
303
|
-
syncBadgeHtml = '<span class="status-badge st-
|
|
330
|
+
syncBadgeHtml = '<span class="status-badge st-warn">' + esc(t("syncBlockedStatic")) + "</span>";
|
|
304
331
|
}
|
|
305
332
|
} else if (state.token) {
|
|
306
333
|
syncBadgeHtml = '<span class="status-badge st-info">' + esc(t("syncChecking")) + "</span>";
|
|
@@ -354,6 +381,13 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
354
381
|
'<div class="kv-row"><span class="kv-label">' + esc(t("tunAdapter")) + '</span><span class="kv-val">' + tunHtml + "</span></div>" +
|
|
355
382
|
'<div class="kv-row"><span class="kv-label">' + esc(t("timezoneLabel")) + '</span><span class="kv-val"><span class="status-badge ' + tzClass + ' tabular">' + esc(r.environmentSummary.systemTimezone) + "</span></span></div>";
|
|
356
383
|
|
|
384
|
+
var retrySyncBtn = document.getElementById("retrySyncBtn");
|
|
385
|
+
if (retrySyncBtn) {
|
|
386
|
+
retrySyncBtn.onclick = function () {
|
|
387
|
+
runBrowserLiveProbes(true);
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
|
|
357
391
|
// Kill-Switch Drill Cabin
|
|
358
392
|
document.getElementById("drillTitle").textContent = t("drillTitle");
|
|
359
393
|
document.getElementById("drillSub").textContent = t("drillSub");
|
|
@@ -570,9 +604,13 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
570
604
|
var badge =
|
|
571
605
|
b.kind === "global-cli-npm-node"
|
|
572
606
|
? '<span class="status-badge st-crit">' + esc(t("npmDanger")) + "</span>"
|
|
573
|
-
: b.
|
|
574
|
-
? '<span class="status-badge st-
|
|
575
|
-
:
|
|
607
|
+
: b.kind === "global-cli-stub"
|
|
608
|
+
? '<span class="status-badge st-warn">' + esc(t("stubWarn")) + "</span>"
|
|
609
|
+
: b.kind === "global-cli-unverified-shim"
|
|
610
|
+
? '<span class="status-badge st-warn">' + esc(t("shimWarn")) + "</span>"
|
|
611
|
+
: b.firewallCovered
|
|
612
|
+
? '<span class="status-badge st-pass">' + esc(t("fwLocked")) + "</span>"
|
|
613
|
+
: '<span class="status-badge st-warn">' + esc(t("fwUnlocked")) + "</span>";
|
|
576
614
|
return (
|
|
577
615
|
'<div class="bin-row">' +
|
|
578
616
|
'<div style="flex:1;min-width:240px">' +
|
|
@@ -598,37 +636,96 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
598
636
|
document.getElementById("btnCloseModal").textContent = t("closeBtn");
|
|
599
637
|
}
|
|
600
638
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
var browserCountry = "";
|
|
639
|
+
function isValidIpLiteral(s) {
|
|
640
|
+
if (!s || typeof s !== "string") return false;
|
|
641
|
+
var v = s.trim();
|
|
642
|
+
return /^(?:\d{1,3}\.){3}\d{1,3}$/.test(v) || /^[a-f0-9:]{3,45}$/i.test(v);
|
|
643
|
+
}
|
|
607
644
|
|
|
645
|
+
async function fetchEchoWithTimeout(url, timeoutMs) {
|
|
646
|
+
var ctrl = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
647
|
+
var timer = ctrl
|
|
648
|
+
? setTimeout(function () {
|
|
649
|
+
try {
|
|
650
|
+
ctrl.abort();
|
|
651
|
+
} catch (_e) {}
|
|
652
|
+
}, timeoutMs)
|
|
653
|
+
: null;
|
|
608
654
|
try {
|
|
609
|
-
var
|
|
610
|
-
if (
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
}
|
|
622
|
-
|
|
655
|
+
var opts = { cache: "no-store" };
|
|
656
|
+
if (ctrl) opts.signal = ctrl.signal;
|
|
657
|
+
return await fetch(url, opts);
|
|
658
|
+
} finally {
|
|
659
|
+
if (timer) clearTimeout(timer);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
// 顺序轮询多组支持 CORS 的 IPv4 优先公共回显端点(无论前一个源是抛异常、403/520 非 200 还是空响应均自动切下一个源)
|
|
664
|
+
async function probeBrowserOutboundEcho() {
|
|
665
|
+
var sources = [
|
|
666
|
+
{ id: "1.1.1.1-trace", url: "https://1.1.1.1/cdn-cgi/trace", kind: "trace" },
|
|
667
|
+
{ id: "1.0.0.1-trace", url: "https://1.0.0.1/cdn-cgi/trace", kind: "trace" },
|
|
668
|
+
{ id: "ipinfo-json", url: "https://ipinfo.io/json", kind: "ipinfo" },
|
|
669
|
+
{ id: "icanhazip-v4", url: "https://ipv4.icanhazip.com", kind: "text" },
|
|
670
|
+
{ id: "ident-v4", url: "https://v4.ident.me", kind: "text" },
|
|
671
|
+
{ id: "cloudflare-trace", url: "https://www.cloudflare.com/cdn-cgi/trace", kind: "trace" }
|
|
672
|
+
];
|
|
673
|
+
|
|
674
|
+
for (var i = 0; i < sources.length; i++) {
|
|
675
|
+
var src = sources[i];
|
|
623
676
|
try {
|
|
624
|
-
var
|
|
625
|
-
if (
|
|
626
|
-
|
|
627
|
-
|
|
677
|
+
var res = await fetchEchoWithTimeout(src.url, 3200);
|
|
678
|
+
if (!res || !res.ok) continue;
|
|
679
|
+
|
|
680
|
+
if (src.kind === "trace") {
|
|
681
|
+
var txt = await res.text();
|
|
682
|
+
var foundIp = "";
|
|
683
|
+
var foundLoc = "";
|
|
684
|
+
txt.split(/\r?\n/).forEach(function (line) {
|
|
685
|
+
var idx = line.indexOf("=");
|
|
686
|
+
if (idx > 0) {
|
|
687
|
+
var k = line.slice(0, idx).trim();
|
|
688
|
+
var v = line.slice(idx + 1).trim();
|
|
689
|
+
if (k === "ip") foundIp = v;
|
|
690
|
+
if (k === "loc") foundLoc = v;
|
|
691
|
+
}
|
|
692
|
+
});
|
|
693
|
+
if (isValidIpLiteral(foundIp)) {
|
|
694
|
+
return { ip: foundIp.trim(), country: foundLoc, source: src.id };
|
|
695
|
+
}
|
|
696
|
+
} else if (src.kind === "ipinfo") {
|
|
697
|
+
var j = await res.json();
|
|
698
|
+
if (j && isValidIpLiteral(j.ip)) {
|
|
699
|
+
return {
|
|
700
|
+
ip: String(j.ip).trim(),
|
|
701
|
+
country: typeof j.country === "string" ? j.country.trim() : "",
|
|
702
|
+
source: src.id
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
} else {
|
|
706
|
+
var rawTxt = (await res.text()).trim();
|
|
707
|
+
if (isValidIpLiteral(rawTxt)) {
|
|
708
|
+
return { ip: rawTxt, country: "", source: src.id };
|
|
709
|
+
}
|
|
628
710
|
}
|
|
629
|
-
} catch (
|
|
711
|
+
} catch (_e) {
|
|
712
|
+
// 被隐私扩展拦截或超时,继续尝试下一个回显源
|
|
713
|
+
}
|
|
630
714
|
}
|
|
631
715
|
|
|
716
|
+
return { ip: "", country: "", source: "" };
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// Live Browser OAuth Sync + WebRTC STUN Probe
|
|
720
|
+
async function runBrowserLiveProbes(isManualRetry) {
|
|
721
|
+
if (!state.token || state.report.demoMode || state.syncProbing) return;
|
|
722
|
+
state.syncProbing = true;
|
|
723
|
+
if (isManualRetry) renderAll();
|
|
724
|
+
|
|
725
|
+
var echoRes = await probeBrowserOutboundEcho();
|
|
726
|
+
var browserIp = echoRes.ip;
|
|
727
|
+
var browserCountry = echoRes.country;
|
|
728
|
+
|
|
632
729
|
// Native WebRTC STUN candidate check
|
|
633
730
|
var webrtcIps = [];
|
|
634
731
|
var webrtcTested = false;
|
|
@@ -678,6 +775,7 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
678
775
|
body: JSON.stringify({
|
|
679
776
|
browserIp: browserIp,
|
|
680
777
|
browserCountry: browserCountry,
|
|
778
|
+
probeSource: echoRes.source,
|
|
681
779
|
webrtcTested: webrtcTested,
|
|
682
780
|
webrtcIps: webrtcIps,
|
|
683
781
|
browserTimezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
@@ -686,9 +784,14 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
686
784
|
});
|
|
687
785
|
if (syncResp.ok) {
|
|
688
786
|
state.report = await syncResp.json();
|
|
689
|
-
renderAll();
|
|
690
787
|
}
|
|
691
788
|
} catch (_e) {}
|
|
789
|
+
|
|
790
|
+
state.syncProbing = false;
|
|
791
|
+
renderAll();
|
|
792
|
+
if (isManualRetry) {
|
|
793
|
+
showToast(browserIp ? t("toastSyncRetryOk") : t("toastSyncRetryBlocked"));
|
|
794
|
+
}
|
|
692
795
|
}
|
|
693
796
|
|
|
694
797
|
async function handleRunDrill() {
|
|
@@ -719,6 +822,7 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
719
822
|
if (data.report) state.report = data.report;
|
|
720
823
|
if (data.restoredOk) {
|
|
721
824
|
showToast(t("toastRestoreOk"));
|
|
825
|
+
runBrowserLiveProbes(false);
|
|
722
826
|
} else {
|
|
723
827
|
showToast(t("toastRestoreFail"));
|
|
724
828
|
}
|
|
@@ -912,7 +1016,13 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
912
1016
|
],
|
|
913
1017
|
[
|
|
914
1018
|
state.lang === "zh" ? "浏览器 vs CLI 出口" : "OAuth Dual-End Sync",
|
|
915
|
-
r.browserSync.matchesCliExit === true
|
|
1019
|
+
r.browserSync.matchesCliExit === true
|
|
1020
|
+
? "SYNCED ✓"
|
|
1021
|
+
: r.browserSync.matchesCliExit === false
|
|
1022
|
+
? "MISMATCH ✕"
|
|
1023
|
+
: r.browserSync.probeBlockedOrFailed
|
|
1024
|
+
? "BLOCKED !"
|
|
1025
|
+
: "PENDING"
|
|
916
1026
|
],
|
|
917
1027
|
[
|
|
918
1028
|
state.lang === "zh" ? "WebRTC UDP 防穿透" : "WebRTC UDP Shield",
|
|
@@ -1060,8 +1170,16 @@ export const CLIENT_SCRIPT = String.raw `
|
|
|
1060
1170
|
py + 225
|
|
1061
1171
|
);
|
|
1062
1172
|
ctx.fillText(
|
|
1063
|
-
"OAuth Sync: " +
|
|
1064
|
-
|
|
1173
|
+
"OAuth Sync: " +
|
|
1174
|
+
(r.browserSync.matchesCliExit === true
|
|
1175
|
+
? "PASS ✓"
|
|
1176
|
+
: r.browserSync.matchesCliExit === false
|
|
1177
|
+
? "MISMATCH ✕"
|
|
1178
|
+
: r.browserSync.probeBlockedOrFailed
|
|
1179
|
+
? "BLOCKED !"
|
|
1180
|
+
: "PENDING") +
|
|
1181
|
+
" | WebRTC: " +
|
|
1182
|
+
(r.browserSync.webrtcHasDomesticOrMismatchLeak ? "LEAK ✕" : "PASS ✓"),
|
|
1065
1183
|
ix + 295,
|
|
1066
1184
|
py + 268
|
|
1067
1185
|
);
|
|
@@ -103,7 +103,13 @@ export function formatMarkdownReport(report, lang = "zh") {
|
|
|
103
103
|
}
|
|
104
104
|
else {
|
|
105
105
|
for (const b of report.binaries) {
|
|
106
|
-
const lockTag = b.
|
|
106
|
+
const lockTag = b.kind === "global-cli-stub"
|
|
107
|
+
? "[STUB]"
|
|
108
|
+
: b.kind === "global-cli-unverified-shim"
|
|
109
|
+
? "[UNVERIFIED-SHIM]"
|
|
110
|
+
: b.firewallCovered
|
|
111
|
+
? "[LOCKED]"
|
|
112
|
+
: "[OPEN]";
|
|
107
113
|
lines.push(`- \`${lockTag}\` **${b.name}** (\`${b.displayPath}\`) — ${pick(b.note)}`);
|
|
108
114
|
}
|
|
109
115
|
}
|