From 35f615202d9a86bc4feea8393fee756b568986f4 Mon Sep 17 00:00:00 2001 From: AniccaY <68173937+AniccaY@users.noreply.github.com> Date: Sun, 14 Sep 2025 23:26:52 +0800 Subject: [PATCH 1/5] Update BundleFile.py Fix CN bundle decrypt : The wrong block was decrypted only LZ4HC need decrypt --- UnityPy/files/BundleFile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnityPy/files/BundleFile.py b/UnityPy/files/BundleFile.py index ed014c92..6c350f9f 100644 --- a/UnityPy/files/BundleFile.py +++ b/UnityPy/files/BundleFile.py @@ -502,7 +502,7 @@ def decompress_data( The decompressed data.""" comp_flag = CompressionFlags(flags & ArchiveFlags.CompressionTypeMask) - if self.decryptor is not None and flags & 0x100: + if self.decryptor is not None and comp_flag == CompressionFlags.LZ4HC and flags & 0x100: compressed_data = self.decryptor.decrypt_block(compressed_data, index) if comp_flag in CompressionHelper.DECOMPRESSION_MAP: From 32d4c1ed82378f1e49a66b1d02a424d5f13b8ad7 Mon Sep 17 00:00:00 2001 From: AniccaY <68173937+AniccaY@users.noreply.github.com> Date: Thu, 18 Sep 2025 15:22:34 +0800 Subject: [PATCH 2/5] Update BundleFile.py Fix CN-Bundle decrypt --- UnityPy/files/BundleFile.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/UnityPy/files/BundleFile.py b/UnityPy/files/BundleFile.py index 6c350f9f..08101add 100644 --- a/UnityPy/files/BundleFile.py +++ b/UnityPy/files/BundleFile.py @@ -502,8 +502,11 @@ def decompress_data( The decompressed data.""" comp_flag = CompressionFlags(flags & ArchiveFlags.CompressionTypeMask) - if self.decryptor is not None and comp_flag == CompressionFlags.LZ4HC and flags & 0x100: - compressed_data = self.decryptor.decrypt_block(compressed_data, index) + if self.decryptor is not None and comp_flag != CompressionFlags.None and flags & 0x100: + try: + compressed_data = self.decryptor.decrypt_block(compressed_data, index) + except: + compressed_data = compressed_data if comp_flag in CompressionHelper.DECOMPRESSION_MAP: return cast( From 12c252b7907c4f4b13814c37417f0a83c3442b91 Mon Sep 17 00:00:00 2001 From: AniccaY <68173937+AniccaY@users.noreply.github.com> Date: Thu, 18 Sep 2025 15:23:59 +0800 Subject: [PATCH 3/5] Update BundleFile.py --- UnityPy/files/BundleFile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnityPy/files/BundleFile.py b/UnityPy/files/BundleFile.py index 08101add..9ef98e63 100644 --- a/UnityPy/files/BundleFile.py +++ b/UnityPy/files/BundleFile.py @@ -502,7 +502,7 @@ def decompress_data( The decompressed data.""" comp_flag = CompressionFlags(flags & ArchiveFlags.CompressionTypeMask) - if self.decryptor is not None and comp_flag != CompressionFlags.None and flags & 0x100: + if self.decryptor is not None and comp_flag != CompressionFlags.NONE and flags & 0x100: try: compressed_data = self.decryptor.decrypt_block(compressed_data, index) except: From 1f1f7d451cf32011b40a328b3e27703b60f6ab4d Mon Sep 17 00:00:00 2001 From: AniccaY <68173937+AniccaY@users.noreply.github.com> Date: Thu, 18 Sep 2025 15:34:58 +0800 Subject: [PATCH 4/5] Update BundleFile.py --- UnityPy/files/BundleFile.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/UnityPy/files/BundleFile.py b/UnityPy/files/BundleFile.py index 9ef98e63..1fc3cf59 100644 --- a/UnityPy/files/BundleFile.py +++ b/UnityPy/files/BundleFile.py @@ -489,7 +489,7 @@ def decompress_data( """ Parameters ---------- - compressed_data : bytes + raw_compressed_data : bytes The compressed data. uncompressed_size : int The uncompressed size of the data. @@ -503,16 +503,20 @@ def decompress_data( comp_flag = CompressionFlags(flags & ArchiveFlags.CompressionTypeMask) if self.decryptor is not None and comp_flag != CompressionFlags.NONE and flags & 0x100: - try: - compressed_data = self.decryptor.decrypt_block(compressed_data, index) - except: - compressed_data = compressed_data + de_compressed_data = self.decryptor.decrypt_block(compressed_data, index) + else: + de_compressed_data = compressed_data if comp_flag in CompressionHelper.DECOMPRESSION_MAP: - return cast( - bytes, - CompressionHelper.DECOMPRESSION_MAP[comp_flag](compressed_data, uncompressed_size), - ) + try: + return cast( + bytes, + CompressionHelper.DECOMPRESSION_MAP[comp_flag](de_compressed_data, uncompressed_size), + ) + except: + return cast( + bytes, + CompressionHelper.DECOMPRESSION_MAP[comp_flag](compressed_data, uncompressed_size),) else: raise ValueError(f"Unknown compression! flag: {flags}, compression flag: {comp_flag.value}") From 055af9fe4a7565ba21597805691ad2a1b0976c4d Mon Sep 17 00:00:00 2001 From: AniccaY <68173937+AniccaY@users.noreply.github.com> Date: Thu, 18 Sep 2025 15:35:42 +0800 Subject: [PATCH 5/5] Update BundleFile.py --- UnityPy/files/BundleFile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnityPy/files/BundleFile.py b/UnityPy/files/BundleFile.py index 1fc3cf59..3d011afa 100644 --- a/UnityPy/files/BundleFile.py +++ b/UnityPy/files/BundleFile.py @@ -489,7 +489,7 @@ def decompress_data( """ Parameters ---------- - raw_compressed_data : bytes + compressed_data : bytes The compressed data. uncompressed_size : int The uncompressed size of the data.