diff --git a/py/Fs/Nca.py b/py/Fs/Nca.py index 7916cc50..d0880887 100644 --- a/py/Fs/Nca.py +++ b/py/Fs/Nca.py @@ -122,6 +122,8 @@ def open(self, file = None, mode = 'rb', cryptoType = -1, cryptoKey = -1, crypto key = self.keyBlock[offset:offset+0x10] #Print.info('dec %d: %s' % (i, hx(key))) self.keys.append(key) + + self.keyStatus = True if self.hasTitleRights(): titleRightsTitleId = self.rightsId.decode()[0:16].upper() @@ -129,7 +131,9 @@ def open(self, file = None, mode = 'rb', cryptoType = -1, cryptoKey = -1, crypto if titleRightsTitleId in Titles.keys() and Titles.get(titleRightsTitleId).key: self.titleKeyDec = Keys.decryptTitleKey(uhx(Titles.get(titleRightsTitleId).key), self.masterKey) else: - Print.info('could not find title key %s!' % titleRightsTitleId) + # Print.info('could not find title key %s!' % titleRightsTitleId) + self.keyStatus = False + else: self.titleKeyDec = self.key() @@ -210,7 +214,6 @@ def __getitem__(self, 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'))) #Print.info('partition complete, seeking') @@ -218,6 +221,8 @@ def open(self, file = None, mode = 'rb', cryptoType = -1, cryptoKey = -1, crypto #Print.info('reading') #Hex.dump(self.header.read(0x200)) #sys.exit() + if self.header.keyStatus != True: + return for i in range(4): hdr = self.header.read(0x200) diff --git a/py/lib/Verify.py b/py/lib/Verify.py index fbe265a4..7af40b31 100644 --- a/py/lib/Verify.py +++ b/py/lib/Verify.py @@ -120,14 +120,16 @@ def verify_decrypt(nspx, vmsg = None): if nspf._path == 'secure': temp_hfs = nspf isCard = True - else: - for file in nspf: - tvmsg = '' - tvmsg += f'\n:0000000000000000 - Content.UNKNOWN' - tvmsg += f'\n> {file._path}\t -> SKIPPED' - tvmsg += f'\n* Partition: {nspf._path}' - print(tvmsg) - vmsg.append(tvmsg) + # elif len(nspf.files) > 0: + # tvmsg = '' + # tvmsg += f'\n:0000000000000000 - Content.UNKNOWN' + # for file in nspf: + # tab = '\t' + # if not file._path.endswith('cnmt.nca'): + # tab += '\t' + # tvmsg += f'\n> {nspf._path}/{file._path}{tab} -> SKIPPED' + # print(tvmsg) + # vmsg.append(tvmsg) for file in temp_hfs: if file._path.endswith(('.nca','.ncz','.tik')): diff --git a/py/ns_extract_hashes.py b/py/ns_extract_hashes.py index 5e424354..fe4d1601 100644 --- a/py/ns_extract_hashes.py +++ b/py/ns_extract_hashes.py @@ -1,3 +1,5 @@ +from binascii import hexlify as hx, unhexlify as uhx + import os import sys diff --git a/py/ns_extract_meta.py b/py/ns_extract_meta.py index a2445486..b9c631d1 100644 --- a/py/ns_extract_meta.py +++ b/py/ns_extract_meta.py @@ -51,7 +51,7 @@ def scan_file(): titleType = FsTools.parse_cnmt_type_n(hx(Cnmt.titleType.to_bytes(byteorder = 'big'))) - print(f':: CNMT: {Cnmt._path}\n') + print(f'\n:: CNMT: {Cnmt._path}\n') print(f'Title ID: {Cnmt.titleId.upper()}') print(f'Version: {Cnmt.version}') print(f'Title Type: {titleType}') diff --git a/py/ns_ticket_info.py b/py/ns_ticket_info.py index 7effe0ba..c7233dcc 100644 --- a/py/ns_ticket_info.py +++ b/py/ns_ticket_info.py @@ -32,11 +32,13 @@ def scan_file(): ipath = os.path.abspath(INCP_PATH) if not os.path.isfile(ipath): return - if not ipath.lower().endswith(('.nsp', '.nsz')): + if not ipath.lower().endswith(('.xci', '.xcz', '.nsp', '.nsz')): return container = factory(Path(ipath).resolve()) container.open(ipath, 'rb') + if ipath.lower().endswith(('.xci', '.xcz')): + container = container.hfs0['secure'] try: for nspf in container: