mirror of
https://github.com/Remik1r3n/maimaiDX-Api.git
synced 2025-06-15 16:57:29 +08:00
实验性 SDGB 1.50,明天见
This commit is contained in:
parent
00776f330d
commit
dc12cb40ff
@ -19,6 +19,11 @@ AesKey = "n7bx6:@Fg_:2;5E89Phy7AyIcpxEQ:R@"
|
|||||||
AesIV = ";;KjR1C3hgB1ovXa"
|
AesIV = ";;KjR1C3hgB1ovXa"
|
||||||
ObfuscateParam = "BEs2D5vW"
|
ObfuscateParam = "BEs2D5vW"
|
||||||
|
|
||||||
|
# 2025
|
||||||
|
AesKey = "a>32bVP7v<63BVLkY[xM>daZ1s9MBP<R"
|
||||||
|
AesIV = "d6xHIKq]1J]Dt^ue"
|
||||||
|
ObfuscateParam = "B44df8yT"
|
||||||
|
|
||||||
class SDGBApiError(Exception):
|
class SDGBApiError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -37,10 +42,10 @@ class AESPKCS7:
|
|||||||
# 加密
|
# 加密
|
||||||
def encrypt(self, content) -> bytes:
|
def encrypt(self, content) -> bytes:
|
||||||
# if content is str, convert to bytes
|
# if content is str, convert to bytes
|
||||||
if isinstance(content, str):
|
#if isinstance(content, str):
|
||||||
encodedData = content.encode('utf-8')
|
# encodedData = content.encode('utf-8')
|
||||||
cipher = AES.new(self.key, self.mode, self.iv)
|
cipher = AES.new(self.key, self.mode, self.iv)
|
||||||
content_padded = pad(encodedData, AES.block_size)
|
content_padded = pad(content, AES.block_size)
|
||||||
encrypted_bytes = cipher.encrypt(content_padded)
|
encrypted_bytes = cipher.encrypt(content_padded)
|
||||||
return encrypted_bytes
|
return encrypted_bytes
|
||||||
# 解密
|
# 解密
|
||||||
@ -66,8 +71,9 @@ def apiSDGB(data:str, targetApi:str, userAgentExtraData:str, noLog:bool=False, t
|
|||||||
maxRetries = 3
|
maxRetries = 3
|
||||||
agentExtra = str(userAgentExtraData)
|
agentExtra = str(userAgentExtraData)
|
||||||
aes = AESPKCS7(AesKey, AesIV)
|
aes = AESPKCS7(AesKey, AesIV)
|
||||||
reqData_encrypted = aes.encrypt(data)
|
# Begin Build
|
||||||
reqData_deflated = zlib.compress(reqData_encrypted)
|
requestDataFinal = aes.encrypt(zlib.compress(data.encode('utf-8')))
|
||||||
|
# End Build
|
||||||
endpoint = "https://maimai-gm.wahlap.com:42081/Maimai2Servlet/"
|
endpoint = "https://maimai-gm.wahlap.com:42081/Maimai2Servlet/"
|
||||||
if not noLog:
|
if not noLog:
|
||||||
logger.debug(f"开始请求 {targetApi},以 {data}")
|
logger.debug(f"开始请求 {targetApi},以 {data}")
|
||||||
@ -83,18 +89,18 @@ def apiSDGB(data:str, targetApi:str, userAgentExtraData:str, noLog:bool=False, t
|
|||||||
# 不使用代理
|
# 不使用代理
|
||||||
logger.debug("不使用代理")
|
logger.debug("不使用代理")
|
||||||
httpClient = httpx.Client(verify=False)
|
httpClient = httpx.Client(verify=False)
|
||||||
responseOriginal = httpClient.post(
|
responseDataRaw = httpClient.post(
|
||||||
url=endpoint + getSDGBApiHash(targetApi),
|
url=endpoint + getSDGBApiHash(targetApi),
|
||||||
headers={
|
headers={
|
||||||
"User-Agent": f"{getSDGBApiHash(targetApi)}#{agentExtra}",
|
"User-Agent": f"{getSDGBApiHash(targetApi)}#{agentExtra}",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"Mai-Encoding": "1.40",
|
"Mai-Encoding": "1.50",
|
||||||
"Accept-Encoding": "",
|
"Accept-Encoding": "",
|
||||||
"Charset": "UTF-8",
|
"Charset": "UTF-8",
|
||||||
"Content-Encoding": "deflate",
|
"Content-Encoding": "deflate",
|
||||||
"Expect": "100-continue"
|
"Expect": "100-continue"
|
||||||
},
|
},
|
||||||
content=reqData_deflated,
|
content=requestDataFinal,
|
||||||
# 经测试,加 Verify 之后速度慢好多,因此建议选择性开
|
# 经测试,加 Verify 之后速度慢好多,因此建议选择性开
|
||||||
#verify=certifi.where(),
|
#verify=certifi.where(),
|
||||||
#verify=False,
|
#verify=False,
|
||||||
@ -102,33 +108,35 @@ def apiSDGB(data:str, targetApi:str, userAgentExtraData:str, noLog:bool=False, t
|
|||||||
)
|
)
|
||||||
|
|
||||||
if not noLog:
|
if not noLog:
|
||||||
logger.info(f"{targetApi} 请求结果: {responseOriginal.status_code}")
|
logger.info(f"{targetApi} 请求结果: {responseDataRaw.status_code}")
|
||||||
|
|
||||||
if responseOriginal.status_code == 200:
|
if responseDataRaw.status_code == 200:
|
||||||
logger.debug("200 OK!")
|
logger.debug("200 OK!")
|
||||||
else:
|
else:
|
||||||
errorMessage = f"请求失败: {responseOriginal.status_code}"
|
errorMessage = f"请求失败: {responseDataRaw.status_code}"
|
||||||
logger.error(errorMessage)
|
logger.error(errorMessage)
|
||||||
raise SDGBRequestError(errorMessage)
|
raise SDGBRequestError(errorMessage)
|
||||||
|
|
||||||
responseRAWContent = responseOriginal.content
|
responseContentRaw = responseDataRaw.content
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
responseDecompressed = zlib.decompress(responseRAWContent)
|
responseContentDecrypted = aes.decrypt(responseContentRaw)
|
||||||
logger.debug("成功解压响应!")
|
|
||||||
except:
|
|
||||||
logger.warning(f"无法解压,得到的原始响应: {responseRAWContent}")
|
|
||||||
raise SDGBResponseError("解压失败")
|
|
||||||
try:
|
|
||||||
resultResponse = aes.decrypt(responseDecompressed)
|
|
||||||
logger.debug(f"成功解密响应!")
|
logger.debug(f"成功解密响应!")
|
||||||
except:
|
except:
|
||||||
logger.warning(f"解密失败,得到的原始响应: {responseDecompressed}")
|
logger.warning(f"解密失败,得到的原始响应: {responseContentRaw}")
|
||||||
raise SDGBResponseError("解密失败")
|
raise SDGBResponseError("解密失败")
|
||||||
|
try:
|
||||||
|
responseDataFinal = zlib.decompress(responseContentDecrypted)
|
||||||
|
logger.debug("成功解压响应!")
|
||||||
|
except:
|
||||||
|
logger.warning(f"无法解压,解密的原始响应: {responseContentDecrypted}")
|
||||||
|
raise SDGBResponseError("解压失败")
|
||||||
|
|
||||||
|
|
||||||
if not noLog:
|
if not noLog:
|
||||||
logger.debug(f"响应: {resultResponse}")
|
logger.debug(f"响应: {responseContentDecrypted}")
|
||||||
return resultResponse
|
return responseContentDecrypted
|
||||||
|
|
||||||
# 异常处理
|
# 异常处理
|
||||||
except SDGBRequestError as e:
|
except SDGBRequestError as e:
|
||||||
@ -174,4 +182,4 @@ def calcSpecialNumber2():
|
|||||||
num2 >>= 1
|
num2 >>= 1
|
||||||
|
|
||||||
return num3
|
return num3
|
||||||
"""
|
"""
|
||||||
|
@ -4,7 +4,7 @@ placeId = 3490
|
|||||||
placeName = "赛博时空枣庄市中店"
|
placeName = "赛博时空枣庄市中店"
|
||||||
clientId = "A63E01E9564"
|
clientId = "A63E01E9564"
|
||||||
|
|
||||||
useProxy = True
|
useProxy = False
|
||||||
proxyUrl = "http://100.104.133.113:33080"
|
proxyUrl = "http://100.104.133.113:33080"
|
||||||
|
|
||||||
loginBonusDBPath = "./Data/loginBonusDB.json"
|
loginBonusDBPath = "./Data/loginBonusDB.json"
|
||||||
|
@ -16,6 +16,9 @@ AES_IV_SDGB_1_40 = ";;KjR1C3hgB1ovXa"
|
|||||||
AES_KEY_SDGA_1_50 = "A;mv5YUpHBK3YxTy5KB^[;5]C2AL50Bq"
|
AES_KEY_SDGA_1_50 = "A;mv5YUpHBK3YxTy5KB^[;5]C2AL50Bq"
|
||||||
AES_IV_SDGA_1_50 = "9FM:sd9xA91X14v]"
|
AES_IV_SDGA_1_50 = "9FM:sd9xA91X14v]"
|
||||||
|
|
||||||
|
AES_KEY_SDGB_1_50 = "a>32bVP7v<63BVLkY[xM>daZ1s9MBP<R"
|
||||||
|
AES_IV_SDGB_1_50 = "d6xHIKq]1J]Dt^ue"
|
||||||
|
|
||||||
class AESPKCS7:
|
class AESPKCS7:
|
||||||
# 实现了 maimai 通讯所用的 AES 加密的类
|
# 实现了 maimai 通讯所用的 AES 加密的类
|
||||||
def __init__(self, key: str, iv: str):
|
def __init__(self, key: str, iv: str):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user