Update BundleFile.py#345
Conversation
Fix CN bundle decrypt : The wrong block was decrypted only LZ4HC need decrypt
|
Do you have enough evidence to prove this? @AniccaY Although LZ4HC compression flag is widely used in many UnityCN-encrypted games, we cannot draw a conclusion that LZ4HC flag is used in ALL the UnityCN-encrypted games. |
|
old version will decrypt type: None Block, cause read bundle error |
|
I'm interested in the asset file you try to decrypt. Could you please provide a sample file and its key to let me investigate deeper? |
|
sample.zip |
|
Thanks. In your sample files, the blocks with compression flag NONE need no decryption. In another word, for NONE compression, UnityPy should return the data as-is without decryption. I think you can use: if self.decryptor is not None and comp_flag != CompressionFlags.NONE and flags & 0x100:
...instead of simply limiting the decryption to LZ4HC only. As you can see in Studio's implementation, such decryption is applied to all the LZ4-series compression. Here's the reference. |
Fix CN-Bundle decrypt
| 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: |
There was a problem hiding this comment.
Such try-except bypass strategy may conceal potential problems. I think we can remove it.
Btw, it's suggested to rename your PR's title to let it reflect actual works.
isHarryh
left a comment
There was a problem hiding this comment.
I don't understand the significance of your new changes.
Please edit the if-statement of L505 only.
|
I can only second all of @isHarryh comments. I did some digging through the TuanjiePlayer just now, |
|
As the PR had unwanted changes and was based on "guesswork" based on the work of others, |
Fix CN bundle decrypt :
The wrong block was decrypted
only LZ4HC need decrypt