blawar / nut

GNU General Public License v3.0
1.13k stars 195 forks source link

[Bug] nut 3.0 KeyError: 'master_key_10' #257

Closed bao3 closed 3 years ago

bao3 commented 3 years ago

To Reproduce

put prod.keys to keys.txt in the nut folder.

Just compress all nsp to nsz ,use the command:

./nut.py --compres-all -t 1

Expected behavior

Additional context

compressing (level 19) /mnt/game/Borderlands Legendary Collection [NSZ]/Borderlands 2 Game of the Year Edition/Borderlands 2 Game of the Year Edition [DLC Unlocker] [010096F00FF23001][v0].nsp -> /mnt/aaa/nut-3.0/_NSPOUT/Borderlands 2 Game of the Year Edition [DLC Unlocker] [010096F00FF23001][v0].nsz COMPRESS WORKER EXCEPTION: 'master_key_10'
NSPs: 39%|######################9 | 125/321 [11:34:31<61:29:38, 1.13ks/B]Traceback (most recent call last): File "/mnt/aaa/nut-3.0/nut/init.py", line 289, in compressWorker nszFile = compress(path, level, output) File "/mnt/aaa/nut-3.0/nut/init.py", line 187, in compress container.open(filePath, 'rb') File "/mnt/aaa/nut-3.0/Fs/Nsp.py", line 183, in open super(Nsp, self).open(path or self.path, mode, cryptoType, cryptoKey, cryptoCounter) File "/mnt/aaa/nut-3.0/Fs/Pfs0.py", line 196, in open self.files[i].open(None, None) File "/mnt/aaa/nut-3.0/Fs/Nca.py", line 336, in open self.partition(0x0, 0xC00, self.header, Fs.Type.Crypto.XTS, uhx(Keys.get('header_key'))) File "/mnt/aaa/nut-3.0/Fs/File.py", line 70, in partition n.open(None, None, cryptoType, cryptoKey, cryptoCounter) File "/mnt/aaa/nut-3.0/Fs/Nca.py", line 123, in open self.keyBlock = Keys.unwrapAesWrappedTitlekey(self.encKeyBlock, self.masterKey) File "/mnt/aaa/nut-3.0/nut/Keys.py", line 82, in unwrapAesWrappedTitlekey keys['masterkey' + str(keyGeneration).zfill(2)]), aes_kek_generation_source, aes_key_generation_source) KeyError: 'master_key_10'

introkun commented 3 years ago

Cannot reproduce. @blawar can you?

introkun commented 3 years ago

Make it _0a for now Though this does need to be fixed

@throwawayay what do you mean?

bao3 commented 3 years ago

I guess he mean to rename key_10 to key_0a in the code

发自我的iPhone

在 2021年1月9日,下午10:43,Sergey Gradovich notifications@github.com 写道:

 Make it _0a for now Though this does need to be fixed

@throwawayay what do you mean?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

introkun commented 3 years ago

I guess he mean to rename key_10 to key_0a in the code 发自我的iPhone 在 2021年1月9日,下午10:43,Sergey Gradovich @.***> 写道:  Make it _0a for now Though this does need to be fixed @throwawayay what do you mean? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

There's no such piece of code with hard-coded key_10.

introkun commented 3 years ago

@throwawayay how about replacing masterKeyName = 'master_key_' + str(i).zfill(2) with masterKeyName = "master_key_%0.2X" % i ? I don't have master_key_0a in my keys.txt, so I won't be able to test it.

introkun commented 3 years ago

Closed due to inactivity

g19i85g commented 3 years ago

I have the same problem. In my keys.txt is no key named master_key_10 only a key named master_key_0a. I think the problem is that the tool is looking for a key named master_key_10 instead of master_key_0a.

blawar commented 3 years ago

this is fixed in 3.2