mirror of
https://github.com/Remik1r3n/maimaiDX-Api.git
synced 2025-05-20 07:27:28 +08:00
解小黑屋概念测试
This commit is contained in:
parent
5727b800fe
commit
49b575d036
@ -8,12 +8,34 @@ from HelperLogInOut import apiLogout
|
|||||||
import json
|
import json
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
import time
|
import time
|
||||||
import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
def isUserLoggedIn(userId):
|
def isUserLoggedIn(userId):
|
||||||
|
return True
|
||||||
return json.loads(apiGetUserPreview(userId))['isLogin']
|
return json.loads(apiGetUserPreview(userId))['isLogin']
|
||||||
|
|
||||||
|
def getUNIXTime(mmddhhmmss, year=2025):
|
||||||
|
# 解析 MMDDHHMMSS 格式的时间,返回 Unix 时间戳
|
||||||
|
try:
|
||||||
|
date_time_str = f"{year}{mmddhhmmss}"
|
||||||
|
date_time_obj = datetime.strptime(date_time_str, '%Y%m%d%H%M%S')
|
||||||
|
# 将 datetime 对象转换为 Unix 时间戳
|
||||||
|
unix_timestamp = int(time.mktime(date_time_obj.timetuple()))
|
||||||
|
logger.info(f"转换出了时间戳: {unix_timestamp}")
|
||||||
|
return unix_timestamp
|
||||||
|
except ValueError as e:
|
||||||
|
print(f"时间格式错误: {e}")
|
||||||
|
return None
|
||||||
|
|
||||||
def logOut(userId, Timestamp):
|
def logOut(userId, Timestamp):
|
||||||
|
DEBUGMODE = True
|
||||||
|
if DEBUGMODE:
|
||||||
|
# 用于调试的时间戳
|
||||||
|
debugRealTimestamp = 1738663945
|
||||||
|
logger.info(f"调试模式: 传入的时间戳和调试时间戳之差: {Timestamp - debugRealTimestamp}")
|
||||||
|
time.sleep(0.2)
|
||||||
|
return True
|
||||||
try:
|
try:
|
||||||
result = apiLogout(Timestamp, userId)
|
result = apiLogout(Timestamp, userId)
|
||||||
loadedResult = json.loads(result)
|
loadedResult = json.loads(result)
|
||||||
@ -22,32 +44,43 @@ def logOut(userId, Timestamp):
|
|||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def forceLogout(userId, beginTimestamp):
|
def isCorrectTimestamp(timestamp, userId):
|
||||||
# 将人类可读的时间转换为 Unix 时间戳
|
'''暴力的检查时间戳是否正确'''
|
||||||
original_timestamp = beginTimestamp
|
logoutResult = logOut(userId, timestamp)
|
||||||
|
if not logoutResult:
|
||||||
# 定义时间范围(前后 20 分钟)
|
return False
|
||||||
time_range = 20 * 60 # 20 分钟,以秒为单位
|
isLoggedOut = not isUserLoggedIn(userId)
|
||||||
|
return isLoggedOut
|
||||||
# 尝试从原始时间戳开始,逐步向两边扩展
|
|
||||||
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}")
|
|
||||||
|
|
||||||
# 示例使用
|
def findCorrectTimestamp(timestamp, userId, max_attempts=1200):
|
||||||
userId = testUid
|
# 初始化偏移量
|
||||||
human_time = "2023-10-01 12:00:00" # 用户输入的人类可读时间
|
offset = 1
|
||||||
forceLogout(userId, human_time)
|
attempts = 0
|
||||||
|
|
||||||
|
while attempts < max_attempts:
|
||||||
|
# 尝试当前时间戳
|
||||||
|
if isCorrectTimestamp(timestamp, userId):
|
||||||
|
print(f"Found correct timestamp: {timestamp}")
|
||||||
|
return timestamp
|
||||||
|
|
||||||
|
# 增加偏移量尝试
|
||||||
|
if isCorrectTimestamp(timestamp + offset, userId):
|
||||||
|
print(f"Found correct timestamp: {timestamp + offset}")
|
||||||
|
return timestamp + offset
|
||||||
|
|
||||||
|
# 减少偏移量尝试
|
||||||
|
if isCorrectTimestamp(timestamp - offset, userId):
|
||||||
|
print(f"Found correct timestamp: {timestamp - offset}")
|
||||||
|
return timestamp - offset
|
||||||
|
|
||||||
|
# 增加尝试次数和偏移量
|
||||||
|
attempts += 2
|
||||||
|
offset += 1
|
||||||
|
|
||||||
|
print("尝试多次后未找到正确时间戳")
|
||||||
|
return None
|
||||||
|
|
||||||
|
human_time = "0204061500"
|
||||||
|
beginTimestamp = getUNIXTime(human_time)
|
||||||
|
print(f"我们将开始用这个时间戳开始尝试: {beginTimestamp}")
|
||||||
|
correctTimestamp = findCorrectTimestamp(beginTimestamp, testUid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user