feat(huya): 支持四段式账号导入接码及旋转/文本点选多级验证码闭环过验

- 账号导入:支持'账号----密码----手机号----接码链接'四段式解析与持久化存储
- 旋转验证码 (rotate_auth / xz):逆向分析官方协议,基于圆周边界采样互相关算法秒级计算旋转还原角度
- 文本点选验证码 (dx_auth):内置成语与古诗名句语料,支持题干菜名提取与古诗/成语挖空正则求解及小图动态合成
- 短信二次验证 (sms_auth2):结合 sms_url 自动轮询接码链接并 Hex 编码提交官方过验
- 前端交互:增加接码标签、在线查询短信验证码、一键自动短信登录与测试接码链接功能
- 回归测试:新增旋转验证、短信接码流与文本点选测试用例(173 passed)
This commit is contained in:
yml2213
2026-09-06 13:56:44 +08:00
parent 4f9a6864eb
commit d3005478a9
15 changed files with 31411 additions and 24 deletions
+96 -5
View File
@@ -48,12 +48,16 @@ class CaptchaCaptureRecord:
"点选验证 (dx_auth)"
if "dx" in auth_type
else (
"短信二次验证 (sms_auth)"
if "sms" in auth_type
"旋转验证 (rotate_auth)"
if "rotate" in auth_type or "xz" in auth_type
else (
"扫码验证 (qr_auth)"
if "qr" in auth_type
else "滑块验证 (pt_auth)"
"短信二次验证 (sms_auth)"
if "sms" in auth_type
else (
"扫码验证 (qr_auth)"
if "qr" in auth_type
else "滑块验证 (pt_auth)"
)
)
)
),
@@ -161,6 +165,93 @@ class CaptchaCaptureRecord:
self._log_summary()
return folder
def capture_rotate_data(
self,
*,
code: str,
dtu_bytes: bytes,
puzzle_bytes: bytes,
restored_bg_bytes: bytes | None = None,
angle: int | float | None = None,
raw_data: dict[str, Any] | None = None,
) -> Path:
"""捕获旋转验证码的所有图片和元数据。"""
folder = self._ensure_target_dir(code)
raw = raw_data or {}
self.meta["code"] = code
self.meta["prompts"] = {
"title": "安全验证 (旋转验证 rotate_auth)",
"default_instruction": "请拖动滑块,将图片旋转至正确位置",
"description": raw.get("description") or raw.get("message") or "",
"tip": raw.get("tip") or "",
}
images_info = {}
if dtu_bytes:
(folder / "bg_scrambled.jpg").write_bytes(dtu_bytes)
images_info["bg_scrambled"] = "bg_scrambled.jpg"
if puzzle_bytes:
(folder / "puzzle.png").write_bytes(puzzle_bytes)
images_info["puzzle"] = "puzzle.png"
if restored_bg_bytes:
(folder / "bg_restored.jpg").write_bytes(restored_bg_bytes)
images_info["bg_restored"] = "bg_restored.jpg"
# 绘制旋转合成标注图
if restored_bg_bytes and puzzle_bytes and angle is not None:
try:
bg = cv2.imdecode(
np.frombuffer(restored_bg_bytes, np.uint8), cv2.IMREAD_COLOR
)
puzzle_raw = cv2.imdecode(
np.frombuffer(puzzle_bytes, np.uint8), cv2.IMREAD_UNCHANGED
)
if bg is not None and puzzle_raw is not None:
M = cv2.getRotationMatrix2D((90.0, 90.0), -float(angle), 1.0)
rotated = cv2.warpAffine(puzzle_raw, M, (180, 180))
alpha = rotated[:, :, 3] / 255.0
composite = bg.copy()
for c in range(3):
composite[0:180, 105:285, c] = (
rotated[:, :, c] * alpha
+ composite[0:180, 105:285, c] * (1 - alpha)
).astype(np.uint8)
cv2.putText(
composite,
f"Angle={int(angle)} deg",
(15, 30),
cv2.FONT_HERSHEY_SIMPLEX,
0.8,
(0, 255, 0),
2,
)
success, buffer = cv2.imencode(".jpg", composite)
if success:
(folder / "annotated.jpg").write_bytes(buffer.tobytes())
images_info["annotated"] = "annotated.jpg"
except Exception as exc: # noqa: BLE001
logger.debug(f"[captcha_capture] 标注旋转图异常: {exc}")
self.meta["images"] = images_info
if angle is not None:
self.meta["solution"] = {"type": "rotate", "angle": int(angle)}
if raw_data:
clean_raw = {
k: v for k, v in raw_data.items() if not str(v).startswith("data:image")
}
(folder / "raw_data.json").write_text(
json.dumps(clean_raw, ensure_ascii=False, indent=2),
encoding="utf-8",
)
self._flush_meta()
self._log_summary()
return folder
def capture_click_data(
self,
*,