chore: move payload scripts to action/

This commit is contained in:
2026-07-07 14:05:23 +08:00
parent 9a94fe8b4e
commit b1b9c7fc10
6 changed files with 4 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
import asyncio
import httpx
from sdgb import MaimaiClient
from sdgb.chime import qr_api
from sdgb.settings import clientId, qrCode
maimai = MaimaiClient()
qrResp = qr_api(qrCode)
userId = qrResp["userID"]
token = qrResp["token"]
async def run_workflow(maimai: MaimaiClient):
async with httpx.AsyncClient(verify=False) as client:
data = {
"userId": userId,
"segaIdAuthKey": "",
"token": token,
"clientId": clientId,
}
result = await maimai.call_api(client, "GetUserPreviewApi", data, userId)
print(result)
# 执行入口
if __name__ == "__main__":
asyncio.run(run_workflow(maimai))

66
action/PowerOn.py Normal file
View File

@@ -0,0 +1,66 @@
from urllib.parse import unquote
import httpx
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad
def enc(key, iv, data):
cipher = AES.new(key, AES.MODE_CBC, iv)
encrypted = cipher.encrypt(data)
return encrypted
def dec(key, iv, data):
de_cipher = AES.new(key, AES.MODE_CBC, iv)
decrypted = de_cipher.decrypt(data)
return decrypted
def hello():
key = bytes([47, 63, 106, 111, 43, 34, 76, 38, 92, 67, 114, 57, 40, 61, 107, 71])
# key = bytes([ 45, 97, 53, 55, 85, 88, 52, 121, 57, 47, 104, 40, 73, 109, 65, 81 ])
iv = bytes.fromhex("00000000000000000000000000000000")
ua = "SDGB;Windows/Lite"
# ua = 'SDHJ;Windows/Lite'
# 构建 payload
content = bytes([0] * 16) + b"title_id=SDGB&title_ver=1.52&client_id=A63E01E6149"
print(f"Content: {content}")
header = bytes.fromhex("00000000000000000000000000000000")
bytes_data = pad(header + content, 16)
encrypted = enc(key, iv, bytes_data)
# --- HTTPX 修改部分 ---
headers = {"User-Agent": ua, "Pragma": "DFI"}
try:
# 发送 POST 请求
# urllib3 的 body 参数在 httpx 中对应 content (用于二进制数据)
r = httpx.post(
"http://at.sys-allnet.cn/net/initialize", content=encrypted, headers=headers
)
# 检查响应状态码 (可选,但在 httpx 中推荐)
# r.raise_for_status()
# urllib3 的 r.data 在 httpx 中对应 r.content
resp_data = r.content
# 解密逻辑保持不变
# 注意这里逻辑是用响应的前16字节作为IV同时解密整个数据然后丢弃前16字节
if len(resp_data) >= 16:
decrypted = dec(key, resp_data[:16], resp_data)
decrypted_bytes = decrypted[16:]
decrypted_str = unquote(decrypted_bytes.decode("UTF-8"), "utf-8")
print(f"Decrypted: {decrypted_str}")
else:
print("Response data too short.")
except httpx.RequestError as e:
print(f"An error occurred while requesting: {e}")
if __name__ == "__main__":
hello()

83
action/UpsertMusic.py Normal file
View File

@@ -0,0 +1,83 @@
import json
import asyncio
import logging
import httpx
from sdgb import MaimaiClient
from sdgb.settings import userId, musicData
from sdgb.payload import (
requestData_UserLogin,
requestData_UserLogout,
requestData_UserPreview,
requestData_UserData,
UserAll_payload,
)
maimai = MaimaiClient()
logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s"
)
logger = logging.getLogger(__name__)
async def run_workflow(self: MaimaiClient):
async with httpx.AsyncClient(verify=False) as client:
# Preview 探测
PreviewResponse = json.loads(
await self.call_api(
client, "GetUserPreviewApi", requestData_UserPreview, userId
)
)
if PreviewResponse["isLogin"]:
logger.error("已在他处登录。")
return
# UserLogin
LoginResponse = json.loads(
await self.call_api(client, "UserLoginApi", requestData_UserLogin, userId)
)
if LoginResponse["returnCode"] != 1:
logger.error("login failed.")
return
loginId = LoginResponse["loginId"]
loginDate = LoginResponse["lastLoginDate"]
# UserData 等
tasks = [
self.call_api(client, "GetUserDataApi", requestData_UserData, userId),
self.call_api(client, "GetUserExtendApi", requestData_UserData, userId),
self.call_api(client, "GetUserOptionApi", requestData_UserData, userId),
self.call_api(client, "GetUserRatingApi", requestData_UserData, userId),
self.call_api(client, "GetUserChargeApi", requestData_UserData, userId),
self.call_api(client, "GetUserActivityApi", requestData_UserData, userId),
self.call_api(
client, "GetUserMissionDataApi", requestData_UserData, userId
),
]
GeneralUserInfo = await asyncio.gather(*tasks)
await asyncio.sleep(60) # 模拟游戏时间
# UserAll
requestData_UserAll = UserAll_payload(
loginId, loginDate, musicData, GeneralUserInfo
)
await self.call_api(client, "UpsertUserAllApi", requestData_UserAll, userId)
# UserLogout
await self.call_api(client, "UserLogoutApi", requestData_UserLogout, userId)
if __name__ == "__main__":
asyncio.run(run_workflow(maimai))

32
action/UserLogoutApi.py Normal file
View File

@@ -0,0 +1,32 @@
import asyncio
import httpx
from sdgb import MaimaiClient
from sdgb.settings import (
userId,
regionId,
placeId,
clientId,
)
maimai = MaimaiClient()
async def run_workflow(maimai: MaimaiClient):
async with httpx.AsyncClient(verify=False) as client:
data = {
"userId": userId,
"accessCode": "",
"regionId": regionId,
"placeId": placeId,
"clientId": clientId,
"dateTime": 1767000000,
"type": 4,
}
await maimai.call_api(client, "UserLogoutApi", data, userId)
# 执行入口
if __name__ == "__main__":
asyncio.run(run_workflow(maimai))