Files
autoPlus/utils/fingerprint.py
2026-01-26 15:04:02 +08:00

82 lines
3.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
浏览器指纹生成模块
用于生成符合 OpenAI Sentinel 要求的浏览器指纹配置数组
"""
import uuid
import time
from typing import List
class BrowserFingerprint:
"""
浏览器指纹生成器
生成 Sentinel SDK 所需的配置数组18 个元素)
"""
def __init__(self, session_id: str = None):
"""
初始化浏览器指纹
参数:
session_id: 会话 IDoai-did如果不提供则自动生成
"""
self.session_id = session_id or str(uuid.uuid4())
self.start_time = time.time()
def get_config_array(self) -> List:
"""
获取 Sentinel SDK 配置数组
返回:
包含 18 个元素的指纹数组
数组结构(从 JS 逆向):
[0] screen dimensions (width*height)
[1] timestamp
[2] memory (hardwareConcurrency)
[3] nonce (动态值PoW 时会修改)
[4] user agent
[5] random element
[6] script src
[7] language
[8] languages (joined)
[9] elapsed time (ms)
[10] random function test
[11] keys
[12] window keys
[13] performance.now()
[14] uuid (session_id)
[15] URL params
[16] hardware concurrency
[17] timeOrigin
"""
elapsed_ms = int((time.time() - self.start_time) * 1000)
return [
1920 * 1080, # [0] screen dimensions
str(int(time.time() * 1000)), # [1] timestamp
8, # [2] hardware concurrency
0, # [3] nonce (placeholder)
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36", # [4] UA
str(0.123456789), # [5] random element
"https://chatgpt.com/_next/static/chunks/sentinel.js", # [6] script src
"en-US", # [7] language
"en-US,en", # [8] languages
elapsed_ms, # [9] elapsed time
"", # [10] random function
"", # [11] keys
"", # [12] window keys
elapsed_ms, # [13] performance.now()
self.session_id, # [14] uuid (oai-did)
"", # [15] URL params
8, # [16] hardware concurrency
int(time.time() * 1000) - elapsed_ms, # [17] timeOrigin
]
# 导出
__all__ = ["BrowserFingerprint"]