From b5e7a59b5f00b2d49556e1d83e82c64e71cc4fba Mon Sep 17 00:00:00 2001 From: Puz Date: Wed, 10 Jul 2024 07:17:12 +0000 Subject: [PATCH] chuni: fix encryption , and added all known iter keys --- titles/chuni/index.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/titles/chuni/index.py b/titles/chuni/index.py index dd49cc6..144f770 100644 --- a/titles/chuni/index.py +++ b/titles/chuni/index.py @@ -94,14 +94,19 @@ class ChuniServlet(BaseServlet): known_iter_counts = { ChuniConstants.VER_CHUNITHM_CRYSTAL_PLUS: 67, + f"{ChuniConstants.VER_CHUNITHM_CRYSTAL_PLUS}_int": 25, # SUPERSTAR ChuniConstants.VER_CHUNITHM_PARADISE: 44, - f"{ChuniConstants.VER_CHUNITHM_PARADISE}_int": 25, + f"{ChuniConstants.VER_CHUNITHM_PARADISE}_int": 51, # SUPERSTAR PLUS ChuniConstants.VER_CHUNITHM_NEW: 54, f"{ChuniConstants.VER_CHUNITHM_NEW}_int": 49, ChuniConstants.VER_CHUNITHM_NEW_PLUS: 25, + f"{ChuniConstants.VER_CHUNITHM_NEW_PLUS}_int": 31, ChuniConstants.VER_CHUNITHM_SUN: 70, + f"{ChuniConstants.VER_CHUNITHM_SUN}_int": 35, ChuniConstants.VER_CHUNITHM_SUN_PLUS: 36, + f"{ChuniConstants.VER_CHUNITHM_SUN_PLUS}_int": 36, ChuniConstants.VER_CHUNITHM_LUMINOUS: 8, + f"{ChuniConstants.VER_CHUNITHM_LUMINOUS}_int": 8, } for version, keys in self.game_cfg.crypto.keys.items(): @@ -233,8 +238,10 @@ class ChuniServlet(BaseServlet): elif version >= 220: # LUMINOUS internal_ver = ChuniConstants.VER_CHUNITHM_LUMINOUS elif game_code == "SDGS": # Int - if version < 110: # SUPERSTAR / SUPERSTAR PLUS - internal_ver = ChuniConstants.VER_CHUNITHM_PARADISE # SUPERSTAR / SUPERSTAR PLUS worked fine with it + if version < 105: # SUPERSTAR + internal_ver = ChuniConstants.VER_CHUNITHM_CRYSTAL_PLUS + elif version >= 105 and version < 110: # SUPERSTAR PLUS *Cursed but needed due to different encryption key + internal_ver = ChuniConstants.VER_CHUNITHM_PARADISE elif version >= 110 and version < 115: # NEW internal_ver = ChuniConstants.VER_CHUNITHM_NEW elif version >= 115 and version < 120: # NEW PLUS!! @@ -353,9 +360,9 @@ class ChuniServlet(BaseServlet): padded = pad(zipped, 16) crypt = AES.new( - bytes.fromhex(self.game_cfg.crypto.keys[internal_ver][0]), + bytes.fromhex(self.game_cfg.crypto.keys[crypto_cfg_key][0]), AES.MODE_CBC, - bytes.fromhex(self.game_cfg.crypto.keys[internal_ver][1]), + bytes.fromhex(self.game_cfg.crypto.keys[crypto_cfg_key][1]), ) return Response(crypt.encrypt(padded))