def print_cnmt(cnmt): print('%016x v%d:' % (cnmt.tid, cnmt.ver)) if cnmt.title_type == 'SystemUpdate': print(' Titles:') for tid, d in cnmt.data.items(): print(' %016x:' % tid) print(' Type: %s' % d['Type']) print(' Version: %d' % d['Version']) else: print(' Total title size: %s' % bytes2human(cnmt.title_size)) print(' Files:') for _, ncas in cnmt.data.items(): if ncas: for nca_id, d in ncas.items(): print(' %032x.nca:' % nca_id) print(' Size: %s' % bytes2human(d['Size'])) print(' SHA256: %s' % hx(d['Hash']).decode())
def _print_dir(self, dir, lvl=0, char=' '): tab = lvl * char string = '' for child in dir.childs: string += '\n' + tab + child.name string += self._print_dir(child, lvl + 1, char) for file in dir.files: string += '\n' + tab + bytes2human(file.size) + '\t' + file.name return string
def print_more(self): print('%s:' % os.path.basename(self.name)) print(' Content type: %s' % self.header.content_type) print(' Size: %s' % bytes2human(self.header.size)) print(' Distribution Type: %s' % ('Gamecard' if self.header.is_game_card else 'Digital')) print(' Title ID: %016x' % self.header.tid) if self.has_rights_id: print(' Rights ID: %032x' % self.rights_id) print(' Master key revision: %d' % self.crypto_type) print(' Encryption type: %s' % ('Titlekey' if self.has_rights_id else 'Standard')) if self.has_rights_id and not self.has_tkey: print('Titlekey not available') return print(' Body key: %s' % hx(self.body_key).decode()) print( memdump(self.header.rsa_sig_1, message=' Fixed key signature: ', length=32)) print( memdump(self.header.rsa_sig_2, message=' NPDM signature: ', length=32)) print() for n, sec in enumerate(self.sections): print('Section %d (%s):' % (n, bytes2human(sec.size))) print(' Type: %s' % ('ExeFS' if sec.is_exefs else sec.fs_type)) print(' Counter: %032x' % ((int.from_bytes(sec.nonce, byteorder='big') << 64) + (sec.section_offset >> 4))) print(' Offset: 0x%x' % sec.offset_in_cont) if sec.section_header.fs_type == 'RomFS': print(' Block Size: 0x%x' % sec.section_header.superblock.lvls[0].block_size) print(' Directories: %d' % sec.fs.dir_nb) else: print(' Block Size: 0x%x' % sec.section_header.superblock.block_size) print(' Files: %d' % sec.fs.file_nb) print(str(sec.fs)) print()
def __str__(self): string = '%s:\n' % os.path.basename(self.name) string += ' Size: %s\n' % bytes2human(self.header.size) string += ' Content type: %s\n' % self.header.content_type string += ' Title ID: %016x\n' % self.header.tid if self.has_rights_id: string += ' Rights ID: %032x\n' % self.rights_id string += ' Master key revision: %d\n' % self.crypto_type string += ' Encryption type: %s\n' % ( 'Titlekey' if self.has_rights_id else 'Standard') if self.has_rights_id and not self.has_tkey: string += 'Titlekey not available' return string string += ' Body key: %s\n\n' % hx(self.body_key).decode() for n, sec in enumerate(self.sections): string += 'Section %d: %s (%s)\n' % (n, ('ExeFS' if sec.is_exefs else sec.fs_type), bytes2human(sec.size)) if sec.section_header.fs_type == 'RomFS': string += ' Directories: %d\n' % sec.fs.dir_nb string += ' Files: %d\n' % sec.fs.file_nb return string