AuthLite PowerOn初步实现和其他改进
This commit is contained in:
33
Standalone/DecryptAuthLite.py
Normal file
33
Standalone/DecryptAuthLite.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# 解密国服 Auth Lite 的包
|
||||
# 仅测试过 PowerOn 请求,其他包不确定是否适用
|
||||
# 仅适用国服 DX2024,其他未测试
|
||||
|
||||
# 完全 Standalone,不依赖于其他文件
|
||||
|
||||
import base64
|
||||
from Crypto.Cipher import AES
|
||||
from urllib.parse import unquote
|
||||
from Crypto.Util.Padding import unpad
|
||||
|
||||
# 密钥从 HDD 提取
|
||||
LITE_AUTH_KEY = bytes([47, 63, 106, 111, 43, 34, 76, 38, 92, 67, 114, 57, 40, 61, 107, 71])
|
||||
LITE_AUTH_IV = bytes.fromhex('00000000000000000000000000000000')
|
||||
|
||||
# 填入你抓包得到的想解密的数据的 base64 编码
|
||||
base64String = "N0PyrjawH/7qA8A28y++3txHDsKuAs5+nib751QiNlJYigvwldPaG7xd0WYXvgqlWY16JIy38GQ8+M4ttaWRNfpWy9l29pC2h2abd4VGhIeWGLbOjc2Bthqhibui76vi4dW+05TsPiyXbOsqHFzScvdByKUtZUobZgrnr/WW+YqRIUdw/ZHBmKBY81JivnVH9AkEyCCP9xubYMjDqi65WhDpcrdMk5nUjHq/O7R1eXr12Es9gXDUruy/H4M7eMt+4kFSDCGpLSFwAEDhba6rpOz0n588nfvXXFlZ+a3ZsZSBYAJPBZ795Ck8ZDIYnEMWMV5nk6qPc2HiBF9ZZw88FlATGC8NqsTSjGX6JJXWDApUaSF5obXMu4LTmMMr0KDt2fQ6VQPkLnTgJ6tsJv1iAQvtcZ9ymn3I4S0XWXGmEq8r7XE7D+pnSJyjUn7bSXb6HOzCQtQc9XYmIbylS2sNkiDXywrxVgmiAXc4Ta8M9aNUb+81QrKj6qqC06DzdYQNBFRxb78X3nGYECEmKBsxIOR7Mf/ZqWYtA28Ob9H5CCUmjLvUaoQ+htJMHfQ9fvvevfu+FxtlJXfw+3UQDiQ1xvSZe2NMCgkLOuwqZ5/5PyoAV9MKzRXT4hBzDoiAIt7bzOH9JcNJkjUtLAjXbnwN6M6zUKpgMK4WYeCwUffNy21GbLVtfIxZZbVhK8A6Ni7j"
|
||||
|
||||
def auth_lite_decrypt(ciphertext: bytes) -> str:
|
||||
# 解密并去除填充
|
||||
cipher = AES.new(LITE_AUTH_KEY, AES.MODE_CBC, LITE_AUTH_IV)
|
||||
decrypted_data = unpad(cipher.decrypt(ciphertext), AES.block_size)
|
||||
# 提取内容并解码
|
||||
content = decrypted_data[16:] # 去除头部的16字节
|
||||
return content.decode('utf-8').strip()
|
||||
|
||||
# 解码 base64
|
||||
decodedData = base64.b64decode(base64String)
|
||||
# 解密数据
|
||||
decryptedData = auth_lite_decrypt(decodedData)
|
||||
print(decryptedData)
|
||||
# 解码 URL 编码
|
||||
print(unquote(decryptedData))
|
||||
66
Standalone/DummyAuthLiteServer.py
Normal file
66
Standalone/DummyAuthLiteServer.py
Normal file
@@ -0,0 +1,66 @@
|
||||
# 舞萌DX Auth-Lite 服务器模拟实现
|
||||
# 仅实现了 /net/initialize 接口,用来处理 PowerOn
|
||||
|
||||
from fastapi import (
|
||||
FastAPI,
|
||||
Request
|
||||
)
|
||||
from fastapi.responses import (
|
||||
HTMLResponse
|
||||
)
|
||||
import uvicorn
|
||||
import httpx
|
||||
from loguru import logger
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Util.Padding import pad, unpad
|
||||
|
||||
# 从 HDD 提取
|
||||
LITE_AUTH_KEY = bytes([47, 63, 106, 111, 43, 34, 76, 38, 92, 67, 114, 57, 40, 61, 107, 71])
|
||||
LITE_AUTH_IV = bytes.fromhex('00000000000000000000000000000000')
|
||||
|
||||
def auth_lite_encrypt(plaintext: str) -> bytes:
|
||||
# 构造数据:16字节头 + 16字节0前缀 + 明文
|
||||
header = bytes(16)
|
||||
content = bytes(16) + plaintext.encode('utf-8')
|
||||
data = header + content
|
||||
# 填充并加密
|
||||
padded_data = pad(data, AES.block_size)
|
||||
cipher = AES.new(LITE_AUTH_KEY, AES.MODE_CBC, LITE_AUTH_IV)
|
||||
return cipher.encrypt(padded_data)
|
||||
|
||||
def auth_lite_decrypt(ciphertext: bytes) -> str:
|
||||
# 解密并去除填充
|
||||
cipher = AES.new(LITE_AUTH_KEY, AES.MODE_CBC, LITE_AUTH_IV)
|
||||
decrypted_data = unpad(cipher.decrypt(ciphertext), AES.block_size)
|
||||
# 提取内容并解码
|
||||
content = decrypted_data[16:] # 去除头部的16字节
|
||||
return content.decode('utf-8').strip()
|
||||
|
||||
def apiOfficialServer(encryptedString: str):
|
||||
url = "http://at.sys-allnet.cn/net/initialize"
|
||||
headers = {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"User-Agent": "SDGB;Windows/Lite"
|
||||
}
|
||||
data = encryptedString
|
||||
response = httpx.post(url, headers=headers, data=data)
|
||||
return response.content
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
USE_OFFICIAL_SERVER = 1
|
||||
|
||||
@app.post('/net/initialize')
|
||||
async def get_data_dummy_api(request: Request):
|
||||
gotRequest = (await request.body())
|
||||
if USE_OFFICIAL_SERVER == 1:
|
||||
decrypted = auth_lite_decrypt(gotRequest)
|
||||
officialResponse = apiOfficialServer(auth_lite_encrypt(decrypted))
|
||||
logger.info(auth_lite_decrypt(officialResponse))
|
||||
return HTMLResponse(officialResponse)
|
||||
else:
|
||||
# todo
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
uvicorn.run(app, host="0.0.0.0", port=80)
|
||||
Reference in New Issue
Block a user