Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All set-masterkeyN commands fail because Titles are not initialized yet #32

Closed
cdriper opened this issue Dec 6, 2018 · 1 comment
Closed

Comments

@cdriper
Copy link

cdriper commented Dec 6, 2018

Script exits with unhandled exception if you try to change master key (any switch like "--set-masterkey4").

Traceback (most recent call last):
  File "nut.py", line 879, in <module>
    f = Fs.Nsp(args.set_masterkey5, 'r+b')
  File "E:\Downloads\nut-master\nut-master\Fs\Nsp.py", line 35, in __init__
    super(Nsp, self).__init__(None, path, mode)
  File "E:\Downloads\nut-master\nut-master\Fs\Pfs0.py", line 24, in __init__
    super(Pfs0, self).__init__(buffer, path, mode, cryptoType, cryptoKey, cryptoCounter)
  File "E:\Downloads\nut-master\nut-master\Fs\BaseFs.py", line 40, in __init__
    super(BaseFs, self).__init__(path, mode, cryptoType, cryptoKey, cryptoCounter)
  File "E:\Downloads\nut-master\nut-master\Fs\File.py", line 381, in __init__
    super(File, self).__init__(path, mode, cryptoType, cryptoKey, cryptoCounter)
  File "E:\Downloads\nut-master\nut-master\Fs\File.py", line 258, in __init__
    super(BufferedFile, self).__init__(path, mode, cryptoType, cryptoKey, cryptoCounter)
  File "E:\Downloads\nut-master\nut-master\Fs\File.py", line 28, in __init__
    self.open(path, mode, cryptoType, cryptoKey, cryptoCounter)
  File "E:\Downloads\nut-master\nut-master\Fs\Nsp.py", line 233, in open
    super(Nsp, self).open(path or self.path, mode, cryptoType, cryptoKey, cryptoCounter)
  File "E:\Downloads\nut-master\nut-master\Fs\Pfs0.py", line 100, in open
    self.files.append(self.partition(offset + headerSize, f.size, f))
  File "E:\Downloads\nut-master\nut-master\Fs\File.py", line 64, in partition
    n.open(None, None, cryptoType, cryptoKey, cryptoCounter)
  File "E:\Downloads\nut-master\nut-master\Fs\Nca.py", line 212, in open
    self.partition(0x0, 0xC00, self.header, Fs.Type.Crypto.XTS, uhx(Keys.get('header_key')))
  File "E:\Downloads\nut-master\nut-master\Fs\File.py", line 64, in partition
    n.open(None, None, cryptoType, cryptoKey, cryptoCounter)
  File "E:\Downloads\nut-master\nut-master\Fs\Nca.py", line 136, in open
    if self.titleId.upper() in Titles.keys() and Titles.get(self.titleId.upper()).key:
  File "lib\Titles.py", line 99, in keys
    return titles.keys()

Possible fix (for a single case):

if args.set_masterkey5:
   initTitles()  #  add this line 
   initFiles()   #  add this line 
   f = Fs.Nsp(args.set_masterkey5, 'r+b')
   f.setMasterKeyRev(5)
   f.flush()
   f.close()
   pass

@blawar
Copy link
Owner

blawar commented Dec 6, 2018

yes that was the fix, I committed to repo thanks.

@blawar blawar closed this as completed Dec 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants