Huge Rewrite!
This commit is contained in:
71
Standalone/DecryptHDD.py
Normal file
71
Standalone/DecryptHDD.py
Normal file
@@ -0,0 +1,71 @@
|
||||
# 解密从 HDD 抓包得到的数据
|
||||
# 兼容 PRiSM 和 CN 2024
|
||||
|
||||
# 完全 Standalone,不依赖于其他文件
|
||||
|
||||
import base64
|
||||
import zlib
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Util.Padding import unpad, pad
|
||||
|
||||
# 密钥和 IV
|
||||
# CN 2024
|
||||
aesKey2024 = "n7bx6:@Fg_:2;5E89Phy7AyIcpxEQ:R@"
|
||||
aesIV2024 = ";;KjR1C3hgB1ovXa"
|
||||
|
||||
# 国际服 PRiSM
|
||||
aesKeyPrism = "A;mv5YUpHBK3YxTy5KB^[;5]C2AL50Bq"
|
||||
aesIVPrism = "9FM:sd9xA91X14v]"
|
||||
|
||||
class AESPKCS7:
|
||||
# 实现了 maimai 通讯所用的 AES 加密的类
|
||||
def __init__(self, key: str, iv: str):
|
||||
self.key = key.encode('utf-8')
|
||||
self.iv = iv.encode('utf-8')
|
||||
self.mode = AES.MODE_CBC
|
||||
# 加密
|
||||
def encrypt(self, content: bytes) -> bytes:
|
||||
cipher = AES.new(self.key, self.mode, self.iv)
|
||||
content_padded = pad(content, AES.block_size)
|
||||
encrypted_bytes = cipher.encrypt(content_padded)
|
||||
return encrypted_bytes
|
||||
# 解密
|
||||
def decrypt(self, encrypted_content: bytes) -> str:
|
||||
cipher = AES.new(self.key, self.mode, self.iv)
|
||||
decrypted_padded = cipher.decrypt(encrypted_content)
|
||||
decrypted = unpad(decrypted_padded, AES.block_size)
|
||||
return decrypted
|
||||
|
||||
def main_sdga():
|
||||
# 填入你的想解密的数据的 base64 编码
|
||||
base64_encoded_data = "KSGm2qo7qVHz1wrK15PckYC5/kLjKcTtEXOgHeHt1Xn6DPdo3pltoPLADHpe8+Wq"
|
||||
|
||||
aes = AESPKCS7(aesKeyPrism, aesIVPrism)
|
||||
|
||||
# 首先解码 base64
|
||||
decodedData = base64.b64decode(base64_encoded_data)
|
||||
# 然后解密数据,PRiSM 是先压缩再加密(which is 正确做法)
|
||||
decryptedData = aes.decrypt(decodedData)
|
||||
# 解压数据
|
||||
decompressedData = zlib.decompress(decryptedData)
|
||||
|
||||
print(str(decompressedData))
|
||||
|
||||
def main_sdgb():
|
||||
# 填入你的想解密的数据的 base64 编码
|
||||
base64_encoded_data = "eJyrTVvpuGwCR32OdodwtVXZ7/Ofmfhin7k/K61q3XNoad1rAPGwECU="
|
||||
|
||||
aes = AESPKCS7(aesKey2024, aesIV2024)
|
||||
|
||||
# 首先解码 base64
|
||||
decodedData = base64.b64decode(base64_encoded_data)
|
||||
# 然后解压数据,CN 2024 是加密后再压缩(纯傻逼
|
||||
decompressedData = zlib.decompress(decodedData)
|
||||
# 最后解密数据
|
||||
decryptedData = aes.decrypt(decompressedData)
|
||||
|
||||
print(str(decryptedData))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main_sdga()
|
||||
Reference in New Issue
Block a user