mirror of
https://github.com/PaiGramTeam/SIMNet.git
synced 2024-11-16 03:55:28 +00:00
✨ Add Get FP
This commit is contained in:
parent
6d551ab25d
commit
07601a4387
@ -1,4 +1,5 @@
|
|||||||
import json as jsonlib
|
import json as jsonlib
|
||||||
|
import time
|
||||||
from typing import Optional, Tuple, Union
|
from typing import Optional, Tuple, Union
|
||||||
|
|
||||||
from simnet.client.base import BaseClient
|
from simnet.client.base import BaseClient
|
||||||
@ -11,9 +12,11 @@ from simnet.client.routes import (
|
|||||||
WEB_ACCOUNT_URL,
|
WEB_ACCOUNT_URL,
|
||||||
QRCODE_URL,
|
QRCODE_URL,
|
||||||
URL,
|
URL,
|
||||||
|
GET_FP_URL,
|
||||||
)
|
)
|
||||||
from simnet.errors import RegionNotSupported
|
from simnet.errors import RegionNotSupported
|
||||||
from simnet.utils.enums import Region
|
from simnet.utils.enums import Region
|
||||||
|
from simnet.utils.hex import get_random_hex_string_of_length
|
||||||
from simnet.utils.player import recognize_game_biz, recognize_server
|
from simnet.utils.player import recognize_game_biz, recognize_server
|
||||||
|
|
||||||
__all__ = ("AuthClient",)
|
__all__ = ("AuthClient",)
|
||||||
@ -590,3 +593,76 @@ class AuthClient(BaseClient):
|
|||||||
"uid": account_id,
|
"uid": account_id,
|
||||||
}
|
}
|
||||||
await self.request_lab(url, method="POST", headers=headers, data=data)
|
await self.request_lab(url, method="POST", headers=headers, data=data)
|
||||||
|
|
||||||
|
async def get_fp(
|
||||||
|
self,
|
||||||
|
device_id: Optional[str] = None,
|
||||||
|
device_fp: Optional[str] = None,
|
||||||
|
extend_properties: Optional[dict] = None,
|
||||||
|
app_name: str = "bbs_cn",
|
||||||
|
platform: int = 2,
|
||||||
|
) -> str:
|
||||||
|
"""
|
||||||
|
Get Device Fingerprint
|
||||||
|
|
||||||
|
Args:
|
||||||
|
device_id (Optional[str]): Device ID, if not provided, use `get_device_id()`.
|
||||||
|
device_fp (Optional[int]): Device fingerprint, if not provided, use `get_device_fp()`.
|
||||||
|
extend_properties (Optional[dict]): Device extension information,
|
||||||
|
defaults to auto-generated if not provided.
|
||||||
|
app_name (str): APP name, defaults to "bbs_cn" if not provided.
|
||||||
|
platform (int): Device platform code, same as client_type in the DS algorithm.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: The device fingerprint.
|
||||||
|
"""
|
||||||
|
seed_time = int(time.time() * 1000)
|
||||||
|
seed_id = get_random_hex_string_of_length(13)
|
||||||
|
if extend_properties is None:
|
||||||
|
model = get_random_hex_string_of_length(6)
|
||||||
|
extend_properties = {
|
||||||
|
"cpuType": "arm64-v8a",
|
||||||
|
"romCapacity": "512",
|
||||||
|
"productName": model,
|
||||||
|
"romRemain": "256",
|
||||||
|
"manufacturer": "XiaoMi",
|
||||||
|
"appMemory": "512",
|
||||||
|
"hostname": "dg02-pool03-kvm87",
|
||||||
|
"screenSize": "1080x1920",
|
||||||
|
"osVersion": "13",
|
||||||
|
"vendor": "中国移动",
|
||||||
|
"accelerometer": "1.4883357x7.1712894x6.2847486",
|
||||||
|
"buildTags": "release-keys",
|
||||||
|
"model": model,
|
||||||
|
"brand": "XiaoMi",
|
||||||
|
"oaid": "",
|
||||||
|
"hardware": "qcom",
|
||||||
|
"deviceType": "OP5913L1",
|
||||||
|
"devId": "REL",
|
||||||
|
"serialNumber": "unknown",
|
||||||
|
"buildTime": "1687848011000",
|
||||||
|
"buildUser": "root",
|
||||||
|
"ramCapacity": "469679",
|
||||||
|
"magnetometer": "20.081251x-27.487501x2.1937501",
|
||||||
|
"display": f"{model}_13.1.0.181(CN01)",
|
||||||
|
"ramRemain": "215344",
|
||||||
|
"deviceInfo": f"XiaoMi/{model}/OP5913L1:13/SKQ1.221119.001/T.118e6c7-5aa23-73911:user/release-keys",
|
||||||
|
"gyroscope": "0.030226856x0.014647375x0.010652636",
|
||||||
|
"vaid": "",
|
||||||
|
"buildType": "user",
|
||||||
|
"sdkVersion": "33",
|
||||||
|
"board": "taro",
|
||||||
|
}
|
||||||
|
ext_fields = jsonlib.dumps(extend_properties)
|
||||||
|
data = {
|
||||||
|
"app_name": app_name,
|
||||||
|
"device_fp": device_fp or self.get_device_fp(),
|
||||||
|
"device_id": device_id or self.get_device_fp(),
|
||||||
|
"ext_fields": ext_fields,
|
||||||
|
"platform": platform,
|
||||||
|
"seed_id": seed_id,
|
||||||
|
"seed_time": seed_time,
|
||||||
|
}
|
||||||
|
new_device_fp = await self.request_lab(GET_FP_URL, method="POST", data=data)
|
||||||
|
self.device_fp = new_device_fp
|
||||||
|
return new_device_fp
|
||||||
|
@ -31,6 +31,7 @@ __all__ = (
|
|||||||
"CODE_HOYOLAB_URL",
|
"CODE_HOYOLAB_URL",
|
||||||
"YSULOG_URL",
|
"YSULOG_URL",
|
||||||
"QRCODE_URL",
|
"QRCODE_URL",
|
||||||
|
"GET_FP_URL",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -317,3 +318,5 @@ CODE_HOYOLAB_URL = GameRoute(
|
|||||||
)
|
)
|
||||||
|
|
||||||
QRCODE_URL = Route("https://hk4e-sdk.mihoyo.com/hk4e_cn/combo/panda/qrcode")
|
QRCODE_URL = Route("https://hk4e-sdk.mihoyo.com/hk4e_cn/combo/panda/qrcode")
|
||||||
|
|
||||||
|
GET_FP_URL = Route("https://public-data-api.mihoyo.com/device-fp/api/getFp")
|
||||||
|
20
simnet/utils/hex.py
Normal file
20
simnet/utils/hex.py
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ("get_random_hex_string_of_length",)
|
||||||
|
|
||||||
|
|
||||||
|
def get_random_hex_string_of_length(length: int):
|
||||||
|
"""
|
||||||
|
Generate a random hexadecimal string of a specified length.
|
||||||
|
|
||||||
|
This function creates a string consisting of randomly selected hexadecimal characters (0-9, a-f).
|
||||||
|
|
||||||
|
Args:
|
||||||
|
length (int): The length of the hexadecimal string to be generated.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: A string containing random hexadecimal characters of the given length.
|
||||||
|
"""
|
||||||
|
random_range = "0123456789abcdef"
|
||||||
|
return "".join(random.choice(random_range) for _ in range(length)) # nosec
|
Loading…
Reference in New Issue
Block a user