Files
hello_js_reverse_skill/tcaptcha/selftest.py
T
yml2213 47ce74b160 refactor(纯算): 移除全部补环境后端,收敛为纯算单一路径 + 修复两处红灯
做了什么:
- 删除 generate_telemetry_node/browser/probe 三个伪造环境后端, 以及 apply_real_environment、
  4 段拼接旧结构、human_dt_ms、generate_collect_pure (crypto.py 955 -> 389 行)
- 遥测只剩纯算: python_keyed = Node 仅提取 XTEA 密钥字 + Python 模板回填 + 教科书 XTEA
- 修复 crypto.py 重复的 xtea_encrypt_block (内置自测从失败到通过), 并并入 selftest
- 修复 glyph_solver 强校验: 改用集成得分矩阵行 argmax 自洽校验, 回归 5/8 -> 8/8
- 移除注释里无证据的 errorCode=12 归因; 移除 12 自动换 IP 重试
- extract_eks 不再写死变量名; UA 常量统一为 Chrome/155
- 文档对齐: ANALYSIS §8 修订 / PROGRESS 重写 / TOOLCHAIN_REPORT §三 更正

为什么:
- 本项目证据账本已证: 12 与遥测后端/出口 IP/静默时长均无关, 补环境无收益且引入脆弱面
- 强校验用单引擎 ocr_text 会误杀正确解 (实测 簿->垂 / 笆->芭 / 筹->努)

怎么验证:
- .venv/bin/python -m tcaptcha.selftest 全绿 (crypto_core + glyph 8/8 + xtea_key)
- 端到端纯算: python / python_keyed 均可解回 '{"cd":[' 开头明文, probe 模式被拒绝
2026-10-11 21:30:26 +08:00

39 lines
934 B
Python

# -*- coding: utf-8 -*-
"""
一键复验入口 (AGENTS.md §1.4 / §5.9)
.venv/bin/python -m tcaptcha.selftest
"""
from __future__ import annotations
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SUITES = [
"tcaptcha.tests.test_crypto_core",
"tcaptcha.tests.test_glyph_solver",
"tcaptcha.tests.test_xtea_key",
]
def main() -> int:
failed = []
for mod in SUITES:
print(f"\n{'=' * 62}\n>>> {mod}\n{'=' * 62}")
rc = subprocess.run([sys.executable, "-m", mod], cwd=str(ROOT),
env={**__import__("os").environ, "PYTHONPATH": str(ROOT)}).returncode
if rc != 0:
failed.append(mod)
print(f"\n{'=' * 62}")
if failed:
print(f"❌ selftest 失败: {failed}")
return 1
print("✅ selftest 全部通过")
return 0
if __name__ == "__main__":
raise SystemExit(main())