forked from Kohaku/maimaiDX-Api
ForceLogout and ChangeVerNum draft
This commit is contained in:
parent
7a1300bc6c
commit
cf9c4d3841
50
ChangeVersionNumber.py
Normal file
50
ChangeVersionNumber.py
Normal file
@ -0,0 +1,50 @@
|
||||
# 改变版本号,实现伪封号和解封号
|
||||
|
||||
from loguru import logger
|
||||
from Static_Settings import *
|
||||
from HelperLogInOut import apiLogin, apiLogout, generateTimestamp
|
||||
from HelperFullPlay import implFullPlayAction
|
||||
|
||||
def implChangeVersionNumber(userId: int, currentLoginTimestamp:int, currentLoginResult, dataVersion="1.40.09", romVersion="1.41.00") -> str:
|
||||
musicData= ({
|
||||
"musicId": 834,
|
||||
"level": 4,
|
||||
"playCount": 1,
|
||||
"achievement": 0,
|
||||
"comboStatus": 0,
|
||||
"syncStatus": 0,
|
||||
"deluxscoreMax": 0,
|
||||
"scoreRank": 0,
|
||||
"extNum1": 0
|
||||
})
|
||||
userAllPatches = {
|
||||
"upsertUserAll": {
|
||||
"userData": [{
|
||||
"lastRomVersion": romVersion,
|
||||
"lastDataVersion": dataVersion
|
||||
}],
|
||||
"userMusicDetailList": [musicData],
|
||||
"isNewMusicDetailList": "1" #1避免覆盖
|
||||
}}
|
||||
logger.info("Changing version number to " + dataVersion + " and " + romVersion)
|
||||
result = implFullPlayAction(userId, currentLoginTimestamp, currentLoginResult, musicData, userAllPatches, True)
|
||||
return result
|
||||
|
||||
if __name__ == "__main__":
|
||||
userId = testUid
|
||||
currentLoginTimestamp = generateTimestamp()
|
||||
loginResult = apiLogin(currentLoginTimestamp, userId)
|
||||
|
||||
musicId = 852 #229 is guruguru wash
|
||||
levelId = 3 #3 is MASTER
|
||||
|
||||
if loginResult['returnCode'] != 1:
|
||||
logger.info("登录失败")
|
||||
exit()
|
||||
try:
|
||||
#logger.info(implDeleteMusicRecord(userId, currentLoginTimestamp, loginResult, musicId, levelId))
|
||||
logger.info(implChangeVersionNumber(userId, currentLoginTimestamp, loginResult, "1.30.00", "1.30.00"))
|
||||
logger.info(apiLogout(currentLoginTimestamp, userId))
|
||||
finally:
|
||||
logger.info(apiLogout(currentLoginTimestamp, userId))
|
||||
#logger.warning("Error")
|
50
ForceLogout.py
Normal file
50
ForceLogout.py
Normal file
@ -0,0 +1,50 @@
|
||||
from Static_Settings import *
|
||||
from API_TitleServer import *
|
||||
from GetPreview import apiGetUserPreview
|
||||
from HelperLogInOut import apiLogout
|
||||
import json
|
||||
from loguru import logger
|
||||
import time
|
||||
import datetime
|
||||
|
||||
def isUserLoggedIn(userId):
|
||||
return json.loads(apiGetUserPreview(userId))['isLogin']
|
||||
|
||||
def logOut(userId, Timestamp):
|
||||
try:
|
||||
result = apiLogout(Timestamp, userId)
|
||||
loadedResult = json.loads(result)
|
||||
if loadedResult['returnCode'] == 1:
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
def forceLogout(userId, beginTimestamp):
|
||||
# 将人类可读的时间转换为 Unix 时间戳
|
||||
original_timestamp = beginTimestamp
|
||||
|
||||
# 定义时间范围(前后 20 分钟)
|
||||
time_range = 20 * 60 # 20 分钟,以秒为单位
|
||||
|
||||
# 尝试从原始时间戳开始,逐步向两边扩展
|
||||
for offset in range(0, time_range + 1):
|
||||
# 尝试往前 offset 秒
|
||||
timestamp = original_timestamp - offset
|
||||
logger.info(f"尝试时间戳: {timestamp}")
|
||||
if logout_user(timestamp, userid):
|
||||
if not is_user_logged_in(userid):
|
||||
print(f"用户 {userid} 已成功登出,使用的时间戳: {timestamp}")
|
||||
return
|
||||
# 尝试往后 offset 秒
|
||||
timestamp = original_timestamp + offset
|
||||
if logout_user(timestamp, userid):
|
||||
if not is_user_logged_in(userid):
|
||||
print(f"用户 {userid} 已成功登出,使用的时间戳: {timestamp}")
|
||||
return
|
||||
|
||||
print(f"无法在前后 20 分钟内登出用户 {userid}")
|
||||
|
||||
# 示例使用
|
||||
userId = testUid
|
||||
human_time = "2023-10-01 12:00:00" # 用户输入的人类可读时间
|
||||
force_logout(userId, human_time)
|
@ -43,7 +43,7 @@ def applyUserAllPatches(userAll, patches):
|
||||
# 否则直接更新或添加key
|
||||
userAll[key] = value
|
||||
|
||||
def implFullPlayAction(userId: int, currentLoginTimestamp:int, currentLoginResult, musicData, userAllPatches) -> str:
|
||||
def implFullPlayAction(userId: int, currentLoginTimestamp:int, currentLoginResult, musicData, userAllPatches, debugMode=False) -> str:
|
||||
'''
|
||||
一份完整的上机实现,可以打 patch 来实现各种功能
|
||||
需要在外部先登录并传入登录结果
|
||||
@ -78,6 +78,12 @@ def implFullPlayAction(userId: int, currentLoginTimestamp:int, currentLoginResul
|
||||
currentUserAll = generateFullUserAll(userId, currentLoginResult, currentLoginTimestamp, currentUserData2, currentSpecialNumber)
|
||||
# 应用参数里的补丁
|
||||
applyUserAllPatches(currentUserAll, userAllPatches)
|
||||
|
||||
# 调试模式下直接输出数据
|
||||
if debugMode:
|
||||
logger.debug("调试模式:当前 UserAll 数据:" + json.dumps(currentUserAll, indent=4))
|
||||
return
|
||||
|
||||
# 建构 Json 数据
|
||||
data = json.dumps(currentUserAll)
|
||||
# 开始上传 UserAll
|
||||
|
Loading…
x
Reference in New Issue
Block a user