Skip to content

Commit

Permalink
fixes for multicontent shitty xci
Browse files Browse the repository at this point in the history
  • Loading branch information
seiya-git committed Nov 1, 2023
1 parent 4c9b084 commit a2364f1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
9 changes: 7 additions & 2 deletions py/Fs/Nca.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,18 @@ 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()

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()

Expand Down Expand Up @@ -210,14 +214,15 @@ 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')
self.header.seek(0x400)
#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)
Expand Down
18 changes: 10 additions & 8 deletions py/lib/Verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')):
Expand Down
2 changes: 2 additions & 0 deletions py/ns_extract_hashes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from binascii import hexlify as hx, unhexlify as uhx

import os
import sys

Expand Down
2 changes: 1 addition & 1 deletion py/ns_extract_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand Down
4 changes: 3 additions & 1 deletion py/ns_ticket_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit a2364f1

Please sign in to comment.