hdid 溯源实测: libhydeviceid.so设备ID, 纯代码不可铸造; 共用登录无碍仅设备维度关联风险
- df/collect 响应含40hex hdid(每次新值)但 WUP 登录拒绝(652B) -> 非同一体系 - runner.js 输出 __HDID__, get_huya_sdid 一并返回 - 文档: hdid 来源/可铸造性/共用风险评估 + 设备池方案
This commit is contained in:
@@ -32,12 +32,16 @@ class HuyaSdidResult:
|
||||
"""sdid 获取结果。"""
|
||||
|
||||
sdid: str = ""
|
||||
hdid: str = "" # df/collect 同响应下发的 40hex 设备ID; 与 WUP 登录的 32hex hdid 非同一体系
|
||||
source: str = ""
|
||||
message: str = ""
|
||||
|
||||
|
||||
def _run_node_runner(state_dir: Path, app_id: str, timeout: tuple[float, float]) -> str:
|
||||
"""调用 node runner,返回 sdid。"""
|
||||
HDID_PREFIX = "__HDID__"
|
||||
|
||||
|
||||
def _run_node_runner(state_dir: Path, app_id: str, timeout: tuple[float, float]) -> tuple[str, str]:
|
||||
"""调用 node runner,返回 (sdid, hdid)。"""
|
||||
node_bin = shutil.which("node")
|
||||
if not node_bin:
|
||||
raise HuyaFingerprintError("未找到 node 可执行文件(hydevice.js 需要 JS 引擎)")
|
||||
@@ -55,10 +59,15 @@ def _run_node_runner(state_dir: Path, app_id: str, timeout: tuple[float, float])
|
||||
except subprocess.TimeoutExpired as exc:
|
||||
raise HuyaFingerprintError(f"hydevice runner 超时({total_timeout}s)") from exc
|
||||
|
||||
sdid, hdid = "", ""
|
||||
for line in (proc.stdout or "").splitlines():
|
||||
line = line.strip()
|
||||
if line.startswith(SDID_PREFIX) and len(line) > len(SDID_PREFIX) + 20:
|
||||
return line[len(SDID_PREFIX):]
|
||||
sdid = line[len(SDID_PREFIX):]
|
||||
if line.startswith(HDID_PREFIX) and len(line) > len(HDID_PREFIX) + 20:
|
||||
hdid = line[len(HDID_PREFIX):]
|
||||
if sdid:
|
||||
return sdid, hdid
|
||||
stderr_tail = (proc.stderr or "").strip().splitlines()
|
||||
detail = stderr_tail[-1][:120] if stderr_tail else f"exit={proc.returncode}"
|
||||
raise HuyaFingerprintError(f"hydevice runner 未返回 sdid: {detail}")
|
||||
@@ -104,10 +113,11 @@ def get_huya_sdid(
|
||||
state_dir = Path(tempfile.gettempdir()) / "huya_fp_state"
|
||||
state_dir = Path(state_dir)
|
||||
try:
|
||||
sdid = _run_node_runner(state_dir, app_id, timeout)
|
||||
sdid, hdid = _run_node_runner(state_dir, app_id, timeout)
|
||||
if sdid:
|
||||
logger.debug("虎牙设备指纹成功(node): sdid={}...", sdid[:24])
|
||||
return HuyaSdidResult(sdid=sdid, source="fingerprint")
|
||||
logger.debug("虎牙设备指纹成功(node): sdid={}... hdid={}...",
|
||||
sdid[:24], hdid[:10])
|
||||
return HuyaSdidResult(sdid=sdid, hdid=hdid, source="fingerprint")
|
||||
except HuyaFingerprintError as exc:
|
||||
logger.warning("虎牙 hydevice 指纹失败: {}", exc)
|
||||
if not allow_fallback:
|
||||
|
||||
Reference in New Issue
Block a user