I found that the basic process of generating x-statsig-id and transaction_id is the same, so I referred to your code and wrote a demo to generate x-statsig-id, and found that I can use this id to call the new chat interface of https://grok.com
this is my:
def generate_x_statsig_id(meta_content_base64, method, path, fingerprint):
"""
生成 x-statsig-id
参数:
- meta_content_base64: 从HTML中提取的meta标签内容(base64编码的字符串)
- method: HTTP请求方法 (GET/POST)
- path: 请求的路径
- fingerprint: 浏览器指纹信息
返回:
- 生成的 x-statsig-id 字符串
"""
# 1. 准备各部分数据
# 1.1 解析meta content (48字节)
try:
meta_content = base64.b64decode(meta_content_base64)
if len(meta_content) != 48:
raise ValueError(f"Meta content 长度应为48字节, 实际为 {len(meta_content)} 字节")
except Exception as e:
raise ValueError(f"Meta content 解析失败: {e}")
# 1.2 生成时间戳部分 (4字节)
base_timestamp = 1682924400 # 2023-05-01 00:00:00 UTC
current_timestamp = int(time.time())
timestamp_offset = current_timestamp - base_timestamp
timestamp_bytes = struct.pack('<I', timestamp_offset) # 小端序编码
# 1.3 生成SHA256片段 (16字节)
# 格式: [请求方法]![路径]![时间戳偏移量] + 指纹信息
hash_input = f"{method}!{path}!{timestamp_offset}obfiowerehiring{fingerprint}"
hash_full = hashlib.sha256(hash_input.encode()).digest()
sha256_fragment = hash_full[:16] # 取前16字节
# 1.4 固定值 (1字节)
fixed_value = bytes([3])
# 2. 组装数据块
data_block = meta_content + timestamp_bytes + sha256_fragment + fixed_value
# 3. 异或加密
xor_key = random.randint(0, 255) # 随机生成0-255之间的异或密钥
# 加密流程: [1字节key] + [异或加密的数据块]
encrypted_data = bytearray([xor_key]) # 第一个字节是密钥
# 对数据块进行异或加密
for byte in data_block:
encrypted_data.append(byte ^ xor_key)
# 4. Base64编码
statsig_id = base64.b64encode(encrypted_data).decode()
# 移除尾部填充的等号(符合观察到的实际格式)
statsig_id = statsig_id.rstrip('=')
return statsig_id
def main():
#
meta_content_base64 = "vc11jOZ8zzYC7cbGMywETDDyF4mWQ9s6lbgUmPtZCfxOQ9OLmWu4KmtNnPijTFRo"
method = "POST"
path = "/rest/app-chat/conversations/new"
fingerprint = "a65af40ae147ae147ae180bd70a3d70a3d70bd70a3d70a3d70ae147ae147ae1800"
# 生成 x-statsig-id
statsig_id = generate_x_statsig_id(
meta_content_base64,
method,
path,
fingerprint
)
print("=" * 60)
print("生成的 x-statsig-id")
print("=" * 60)
print(statsig_id)
But I still can't find how the fingerprint parameter is generated. I only know that it is processed by fingerprint information. I have been looking for it for almost a week. I am so sad. I really want to know the source of fingerprint. I am here to ask you for advice and learn from you.
I found that the basic process of generating x-statsig-id and transaction_id is the same, so I referred to your code and wrote a demo to generate x-statsig-id, and found that I can use this id to call the new chat interface of https://grok.com
this is my:
def generate_x_statsig_id(meta_content_base64, method, path, fingerprint):
"""
生成 x-statsig-id
def main():
#
meta_content_base64 = "vc11jOZ8zzYC7cbGMywETDDyF4mWQ9s6lbgUmPtZCfxOQ9OLmWu4KmtNnPijTFRo"
method = "POST"
path = "/rest/app-chat/conversations/new"
But I still can't find how the fingerprint parameter is generated. I only know that it is processed by fingerprint information. I have been looking for it for almost a week. I am so sad. I really want to know the source of fingerprint. I am here to ask you for advice and learn from you.