diff --git a/py/Fs/Nca.py b/py/Fs/Nca.py index d088088..1acaf56 100644 --- a/py/Fs/Nca.py +++ b/py/Fs/Nca.py @@ -213,6 +213,7 @@ def __getitem__(self, key): return self.sectionFilesystems[key] def open(self, file = None, mode = 'rb', cryptoType = -1, cryptoKey = -1, cryptoCounter = -1): + super(Nca, self).open(file, mode, cryptoType, cryptoKey, cryptoCounter) self.header = NcaHeader() self.partition(0x0, 0xC00, self.header, Fs.Type.Crypto.XTS, uhx(Keys.get('header_key'))) diff --git a/py/lib/Verify.py b/py/lib/Verify.py index 7af40b3..e8918d7 100644 --- a/py/lib/Verify.py +++ b/py/lib/Verify.py @@ -236,21 +236,32 @@ def verify_decrypt(nspx, vmsg = None): tik_file = file check_tik = False + tik_data = Fs.Ticket.Ticket() + print(tik_data.__dict__) for f in temp_hfs: - if f._path.endswith('.nca'): - if check_tik == False and f.header.getRightsId() != 0: - check_tik = VerifyTools.verify_key(temp_hfs, f._path, tik_file) - if check_tik == True: - break - if f._path.endswith('.ncz'): - tncz = FsTools.get_ncz_data(f) - if check_tik == False and tncz.header.getRightsId() != 0: - check_tik = 'ncz' - break + if f._path.endswith('.tik') and f._path == tik_file: + tik_data = f + break - if len(titlerights) < 1: + if len(titlerights) < 1 or tik_data.rightsId == 0 or tik_data.rightsId == None: check_tik = 'unused' + if check_tik == False: + for f in temp_hfs: + if f._path.endswith('.nca'): + if f.header.getRightsId() == tik_data.rightsId and f.header.keyStatus == False: + check_tik = 'nca' + break + if f.header.getRightsId() == tik_data.rightsId: + check_tik = VerifyTools.verify_key(temp_hfs, f._path, tik_file) + if check_tik == True: + break + if f._path.endswith('.ncz'): + tncz = FsTools.get_ncz_data(f) + if tncz.header.getRightsId() == tik_data.rightsId: + check_tik = 'ncz' + break + cert_file = f'{tik_file[:-3]}cert' if not cert_file in listed_certs: cert_message += f'\n:{cert_file[:16].upper()} - Content.CERTIFICATE' @@ -288,6 +299,10 @@ def verify_decrypt(nspx, vmsg = None): tvmsg = f'> {file}\t\t -> ncz file needs HASH check' print(tvmsg) vmsg.append(tvmsg) + elif file.endswith('.tik') and correct == 'nca': + tvmsg = f'> {file}\t\t -> is EXISTS' + print(tvmsg) + vmsg.append(tvmsg) elif file.endswith('.tik') and correct == 'ncz': tvmsg = f'> {file}\t\t -> is EXISTS' print(tvmsg) diff --git a/py/nut/Keys.py b/py/nut/Keys.py index 735d0d5..9da6d72 100644 --- a/py/nut/Keys.py +++ b/py/nut/Keys.py @@ -188,9 +188,9 @@ def load(fileName): errorMsg = "" for kf in keyfiles: if errorMsg != "": - errorMsg += "or " - errorMsg += f"{str(kf)} not found\n" - errorMsg += "\nPlease dump your keys using https://github.com/shchmue/Lockpick_RCM/releases\n" + errorMsg += "\nor " + errorMsg += f"{str(kf)}" + errorMsg += " not found\n\nPlease dump your keys using https://github.com/shchmue/Lockpick_RCM/releases\n" Print.error(errorMsg) input("Press Enter to exit...") sys.exit(1)