Skip to content

Commit b811a29

Browse files
committed
1.22.2 - UnityCN encryption flag fix for newer versions that use 0x1000 instead of 0x400
1 parent 278757c commit b811a29

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

UnityPy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "1.22.1"
1+
__version__ = "1.22.2"
22

33
from .environment import Environment as Environment
44
from .helpers.ArchiveStorageManager import (

UnityPy/enums/BundleFile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ class ArchiveFlags(IntFlag):
2323
BlocksInfoAtTheEnd = 0x80
2424
OldWebPluginCompatibility = 0x100
2525
BlockInfoNeedPaddingAtStart = 0x200
26-
UsesAssetBundleEncryption = 0x400
26+
UsesAssetBundleEncryption = 0x1400 # old: 0x400, new: 0x1000

UnityPy/helpers/ArchiveStorageManager.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ def __init__(self, reader: EndianBinaryReader):
7575

7676
if DECRYPT_KEY is None:
7777
raise LookupError(
78-
"\n".join([
79-
"The BundleFile is encrypted, but no key was provided!",
80-
"You can set the key via UnityPy.set_assetbundle_decrypt_key(key).",
81-
"To try brute-forcing the key, use UnityPy.helpers.ArchiveStorageManager.brute_force_key(fp, key_sig, data_sig)",
82-
f"with key_sig = {self.key_sig}, data_sig = {self.data_sig},"
83-
"and fp being the path to global-metadata.dat or a memory dump.",
84-
])
78+
"\n".join(
79+
[
80+
"The BundleFile is encrypted, but no key was provided!",
81+
"You can set the key via UnityPy.set_assetbundle_decrypt_key(key).",
82+
"To try brute-forcing the key, use UnityPy.helpers.ArchiveStorageManager.brute_force_key(fp, key_sig, data_sig)",
83+
f"with key_sig = {self.key_sig}, data_sig = {self.data_sig},"
84+
"and fp being the path to global-metadata.dat or a memory dump.",
85+
]
86+
)
8587
)
8688

8789
signature = decrypt_key(self.key_sig, self.data_sig, DECRYPT_KEY)
@@ -146,3 +148,6 @@ def decrypt(self, data: Union[bytearray, memoryview], index: int, remaining: int
146148
b, offset, index = self.decrypt_byte(data, offset, index)
147149

148150
return offset
151+
152+
# def encrypt(self, data: bytes):
153+
# # TODO: patch BundleFile encryption flag to keep either 0x1000 or 0x400

0 commit comments

Comments
 (0)