Ejemplo n.º 1
0
    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))
        # exit()

        if self._path is not None and self._path.endswith('.ncz'):
            return

        for i in range(4):
            hdr = self.header.read(0x200)
            section = BaseFs(hdr, cryptoKey=self.header.titleKeyDec)
            fs = GetSectionFilesystem(hdr, cryptoKey=-1)
            #Print.info('fs type = ' + hex(fs.fsType))
            #Print.info('fs crypto = ' + hex(fs.cryptoType))
            #Print.info('st end offset = ' + str(self.header.sectionTables[i].endOffset - self.header.sectionTables[i].offset))
            #Print.info('fs offset = ' + hex(self.header.sectionTables[i].offset))
            #Print.info('fs section start = ' + hex(fs.sectionStart))
            #Print.info('titleKey = ' + hex(self.header.titleKeyDec))

            self.partition(self.header.sectionTables[i].offset,
                           self.header.sectionTables[i].endOffset -
                           self.header.sectionTables[i].offset,
                           section,
                           cryptoKey=self.header.titleKeyDec)

            try:
                section.partition(fs.sectionStart,
                                  section.size - fs.sectionStart, fs)
            except BaseException as e:
                pass
                # Print.info(e)
                # raise

            if fs.fsType:
                self.sectionFilesystems.append(fs)
                self.sections.append(section)

            try:
                fs.open(None, 'rb')
            except BaseException as e:
                Print.error(str(e))
                traceback.print_exc(file=sys.stdout)

        self.titleKeyDec = None
Ejemplo n.º 2
0
def GetSectionFilesystem(buffer, cryptoKey):
    fsType = buffer[0x3]
    if fsType == Fs.Type.Fs.PFS0:
        return Pfs0(buffer, cryptoKey=cryptoKey)

    if fsType == Fs.Type.Fs.ROMFS:
        return Rom(buffer, cryptoKey=cryptoKey)

    return BaseFs(buffer, cryptoKey=cryptoKey)
Ejemplo n.º 3
0
Archivo: Pfs0.py Proyecto: stungkit/nut
	def __init__(self, buffer, path=None, mode=None, cryptoType=-1, cryptoKey=-1, cryptoCounter=-1):
		BaseFs.__init__(self, buffer, path, mode, cryptoType, cryptoKey, cryptoCounter)

		if buffer:
			self.size = int.from_bytes(buffer[0x48:0x50], byteorder='little', signed=False)
			self.sectionStart = int.from_bytes(buffer[0x40:0x48], byteorder='little', signed=False)