实验性 SDGB 1.50,明天见

This commit is contained in:
Remik1r3n 2025-06-11 01:32:55 +08:00
parent 00776f330d
commit dc12cb40ff
3 changed files with 35 additions and 24 deletions

View File

@ -19,6 +19,11 @@ AesKey = "n7bx6:@Fg_:2;5E89Phy7AyIcpxEQ:R@"
AesIV = ";;KjR1C3hgB1ovXa"
ObfuscateParam = "BEs2D5vW"
# 2025
AesKey = "a>32bVP7v<63BVLkY[xM>daZ1s9MBP<R"
AesIV = "d6xHIKq]1J]Dt^ue"
ObfuscateParam = "B44df8yT"
class SDGBApiError(Exception):
pass
@ -37,10 +42,10 @@ class AESPKCS7:
# 加密
def encrypt(self, content) -> bytes:
# if content is str, convert to bytes
if isinstance(content, str):
encodedData = content.encode('utf-8')
#if isinstance(content, str):
# encodedData = content.encode('utf-8')
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)
return encrypted_bytes
# 解密
@ -66,8 +71,9 @@ def apiSDGB(data:str, targetApi:str, userAgentExtraData:str, noLog:bool=False, t
maxRetries = 3
agentExtra = str(userAgentExtraData)
aes = AESPKCS7(AesKey, AesIV)
reqData_encrypted = aes.encrypt(data)
reqData_deflated = zlib.compress(reqData_encrypted)
# Begin Build
requestDataFinal = aes.encrypt(zlib.compress(data.encode('utf-8')))
# End Build
endpoint = "https://maimai-gm.wahlap.com:42081/Maimai2Servlet/"
if not noLog:
logger.debug(f"开始请求 {targetApi},以 {data}")
@ -83,18 +89,18 @@ def apiSDGB(data:str, targetApi:str, userAgentExtraData:str, noLog:bool=False, t
# 不使用代理
logger.debug("不使用代理")
httpClient = httpx.Client(verify=False)
responseOriginal = httpClient.post(
responseDataRaw = httpClient.post(
url=endpoint + getSDGBApiHash(targetApi),
headers={
"User-Agent": f"{getSDGBApiHash(targetApi)}#{agentExtra}",
"Content-Type": "application/json",
"Mai-Encoding": "1.40",
"Mai-Encoding": "1.50",
"Accept-Encoding": "",
"Charset": "UTF-8",
"Content-Encoding": "deflate",
"Expect": "100-continue"
},
content=reqData_deflated,
content=requestDataFinal,
# 经测试,加 Verify 之后速度慢好多,因此建议选择性开
#verify=certifi.where(),
#verify=False,
@ -102,33 +108,35 @@ def apiSDGB(data:str, targetApi:str, userAgentExtraData:str, noLog:bool=False, t
)
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!")
else:
errorMessage = f"请求失败: {responseOriginal.status_code}"
errorMessage = f"请求失败: {responseDataRaw.status_code}"
logger.error(errorMessage)
raise SDGBRequestError(errorMessage)
responseRAWContent = responseOriginal.content
responseContentRaw = responseDataRaw.content
try:
responseDecompressed = zlib.decompress(responseRAWContent)
logger.debug("成功解压响应!")
except:
logger.warning(f"无法解压,得到的原始响应: {responseRAWContent}")
raise SDGBResponseError("解压失败")
try:
resultResponse = aes.decrypt(responseDecompressed)
responseContentDecrypted = aes.decrypt(responseContentRaw)
logger.debug(f"成功解密响应!")
except:
logger.warning(f"解密失败,得到的原始响应: {responseDecompressed}")
logger.warning(f"解密失败,得到的原始响应: {responseContentRaw}")
raise SDGBResponseError("解密失败")
try:
responseDataFinal = zlib.decompress(responseContentDecrypted)
logger.debug("成功解压响应!")
except:
logger.warning(f"无法解压,解密的原始响应: {responseContentDecrypted}")
raise SDGBResponseError("解压失败")
if not noLog:
logger.debug(f"响应: {resultResponse}")
return resultResponse
logger.debug(f"响应: {responseContentDecrypted}")
return responseContentDecrypted
# 异常处理
except SDGBRequestError as e:
@ -174,4 +182,4 @@ def calcSpecialNumber2():
num2 >>= 1
return num3
"""
"""

View File

@ -4,7 +4,7 @@ placeId = 3490
placeName = "赛博时空枣庄市中店"
clientId = "A63E01E9564"
useProxy = True
useProxy = False
proxyUrl = "http://100.104.133.113:33080"
loginBonusDBPath = "./Data/loginBonusDB.json"

View File

@ -16,6 +16,9 @@ AES_IV_SDGB_1_40 = ";;KjR1C3hgB1ovXa"
AES_KEY_SDGA_1_50 = "A;mv5YUpHBK3YxTy5KB^[;5]C2AL50Bq"
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:
# 实现了 maimai 通讯所用的 AES 加密的类
def __init__(self, key: str, iv: str):