Exemple #1
0
 def get_FW_number(self, printdata=False):
     import sq_tools
     fwver = 0
     for nspF in self.hfs0:
         if str(nspF._path) == "update":
             for nca in nspF:
                 if type(nca) == Nca:
                     if str(nca.header.contentType) == 'Content.META':
                         for f in nca:
                             for cnmt in f:
                                 nca.rewind()
                                 f.rewind()
                                 cnmt.rewind()
                                 titleid = cnmt.readInt64()
                                 titleid2 = str(
                                     hx(titleid.to_bytes(8,
                                                         byteorder='big')))
                                 titleid2 = titleid2[2:-1]
                                 titleversion = cnmt.read(0x4)
                                 version = int.from_bytes(
                                     titleversion, byteorder='little')
                                 if fwver < version:
                                     fwver = version
                                 if printdata != False:
                                     FWnumber = sq_tools.getFWRangeRSV(
                                         version)
                                     print('- {}: {}'.format(
                                         str(nca._path), str(FWnumber)))
     FWnumber = sq_tools.getFWRangeRSV(fwver)
     FWnumber = FWnumber[1:-1]
     return FWnumber, fwver
def cnmt_data(cnmt, nca, nca_name):
    crypto1 = nca.header.getCryptoType()
    crypto2 = nca.header.getCryptoType2()
    if crypto2 > crypto1:
        keygeneration = crypto2
    if crypto2 <= crypto1:
        keygeneration = crypto1
    cnmt.seek(0)
    titleid = readInt64(cnmt)
    titleid2 = str(hx(titleid.to_bytes(8, byteorder='big')))
    titleid2 = titleid2[2:-1]
    titleid = (str(hx(titleid.to_bytes(8, byteorder='big')))[2:-1]).upper()
    titleversion = cnmt.read(0x4)
    titleversion = str(int.from_bytes(titleversion, byteorder='little'))
    type_n = cnmt.read(0x1)
    cnmt.seek(0xE)
    offset = readInt16(cnmt)
    content_entries = readInt16(cnmt)
    meta_entries = readInt16(cnmt)
    cnmt.seek(0x20)
    base_ID = readInt64(cnmt)
    base_ID = (str(hx(base_ID.to_bytes(8, byteorder='big')))[2:-1]).upper()
    cnmt.seek(0x28)
    min_sversion = readInt32(cnmt)
    length_of_emeta = readInt32(cnmt)
    content_type_cnmt = None
    if content_type_cnmt != 'AddOnContent':
        RSV = str(min_sversion)
        RSV = sq_tools.getFWRangeRSV(int(RSV))
        RGV = 0
    if content_type_cnmt == 'AddOnContent':
        RSV_rq_min = sq_tools.getMinRSV(keygeneration, 0)
        RSV = sq_tools.getFWRangeRSV(int(RSV_rq_min))
        RGV = str(min_sversion)
    if str(hx(type_n)) == "b'1'":
        ctype = 'SystemProgram'
    if str(hx(type_n)) == "b'2'":
        ctype = 'SystemData'
    if str(hx(type_n)) == "b'3'":
        ctype = 'SystemUpdate'
    if str(hx(type_n)) == "b'4'":
        ctype = 'BootImagePackage'
    if str(hx(type_n)) == "b'5'":
        ctype = 'BootImagePackageSafe'
    if str(hx(type_n)) == "b'80'":
        ctype = 'GAME'
    if str(hx(type_n)) == "b'81'":
        ctype = 'UPDATE'
    if str(hx(type_n)) == "b'82'":
        ctype = 'DLC'
    if str(hx(type_n)) == "b'83'":
        ctype = 'Delta'
    metasdkversion = nca.get_sdkversion()
    programSDKversion = None
    dataSDKversion = None
    if content_type_cnmt == 'AddOnContent':
        exesdkversion = dataSDKversion
    if content_type_cnmt != 'AddOnContent':
        exesdkversion = programSDKversion
    ncadata = list()
    hasHtmlManual = False
    Installedsize = int(nca.header.size)
    DeltaSize = 0
    cnmt.seek(0x20 + offset)
    for i in range(content_entries):
        data = {}
        vhash = cnmt.read(0x20)
        vhash = str(hx(vhash))
        NcaId = cnmt.read(0x10)
        NcaId = str(hx(NcaId))
        size = cnmt.read(0x6)
        size = str(int.from_bytes(size, byteorder='little', signed=True))
        ncatype = cnmt.read(0x1)
        ncatype = str(int.from_bytes(ncatype, byteorder='little', signed=True))
        ncatype = sq_tools.getmetacontenttype(ncatype)
        unknown = cnmt.read(0x1)
        data['NcaId'] = NcaId[2:-1]
        data['NCAtype'] = ncatype
        data['Size'] = size
        data['Hash'] = vhash[2:-1]
        if ncatype != "DeltaFragment":
            Installedsize = Installedsize + int(size)
        else:
            DeltaSize = DeltaSize + int(size)
        if ncatype == "HtmlDocument":
            hasHtmlManual = True
        ncadata.append(data)
    cnmtdata = {}
    metaname = str(nca_name)
    metaname = metaname[:-9]
    nca.rewind()
    block = nca.read()
    nsha = sha256(block).hexdigest()
    cnmtdata['NcaId'] = metaname
    cnmtdata['NCAtype'] = 'Meta'
    cnmtdata['Size'] = str(nca.header.size)
    cnmtdata['Hash'] = str(nsha)
    ncadata.append(cnmtdata)
    if int(crypto2) > 9:
        kg_ = str(hex(int(str(crypto2))))[2:]
    else:
        kg_ = str(crypto2)
    if len(str(kg_)) == 1:
        rightsId = str(titleid2).lower() + '000000000000000' + kg_
    elif len(str(kg_)) == 2:
        rightsId = str(titleid2) + '00000000000000' + kg_
    cnmt_dict = {
        'titleid': titleid,
        'titleversion': titleversion,
        'base_ID': base_ID,
        'keygeneration': keygeneration,
        'rightsId': rightsId,
        'RSV': RSV,
        'RGV': RGV,
        'ctype': ctype,
        'metasdkversion': metasdkversion,
        'exesdkversion': exesdkversion,
        'hasHtmlManual': hasHtmlManual,
        'Installedsize': Installedsize,
        'DeltaSize': DeltaSize,
        'ncadata': ncadata
    }
    return cnmt_dict
Exemple #3
0
def getinfo(filename):
    print('* Retrieving Game Information')
    if filename.endswith('.nsp') or filename.endswith(
            '.nsx') or filename.endswith('.nsz'):
        f = Fs.ChromeNsp(filename, 'rb')
    elif filename.endswith('.xci') or filename.endswith('.xcz'):
        f = Fs.ChromeXci(filename)
    else:
        return []
    dict = f.return_DBdict()
    try:
        ModuleId, BuildID8, BuildID16 = f.read_buildid()
        ModuleId = sq_tools.trimm_module_id(ModuleId)
    except:
        ModuleId = "-"
        BuildID8 = "-"
        BuildID16 = "-"
    try:
        MinRSV = sq_tools.getMinRSV(dict['keygeneration'], dict['RSV'])
        RSV_rq_min = sq_tools.getFWRangeRSV(MinRSV)
        FW_rq = sq_tools.getFWRangeKG(dict['keygeneration'])
    except:
        MinRSV = "-"
        RSV_rq_min = "-"
        FW_rq = "-"
    try:
        RGV = dict['RGV']
        RS_number = int(int(RGV) / 65536)
    except:
        RGV = "0"
        RS_number = "0"
    send_ = list()
    try:
        if str(dict['Type']).upper() == 'DLC':
            send_.append(dict['contentname'])
        else:
            send_.append(dict['baseName'])
    except:
        send_.append('-')
    try:
        send_.append(dict['editor'])
    except:
        send_.append('-')
    try:
        send_.append(dict['id'])
    except:
        send_.append('-')
    try:
        send_.append(dict['version'])
    except:
        send_.append('-')
    try:
        send_.append(dict['Type'])
    except:
        send_.append('-')
    try:
        send_.append(dict['dispversion'])
    except:
        send_.append('-')
    try:
        send_.append(dict['metasdkversion'])
    except:
        send_.append('-')
    try:
        send_.append(dict['exesdkversion'])
    except:
        send_.append('-')
    try:
        lang = str((', '.join(dict['languages'])))
        send_.append(lang)
    except:
        send_.append('-')
    try:
        send_.append(dict['RSV'])
    except:
        send_.append('-')
    try:
        send_.append(str(dict['keygeneration']) + " -> " + FW_rq)
    except:
        send_.append('-')
    try:
        send_.append(dict['nsuId'])
    except:
        send_.append('-')
    try:
        genres = str((', '.join(dict['genretags'])))
        send_.append(genres)
    except:
        send_.append('-')
    try:
        ratags = str((', '.join(dict['ratingtags'])))
        send_.append(ratags)
    except:
        send_.append('-')
    try:
        send_.append(dict['worldreleasedate'])
    except:
        send_.append('-')
    try:
        send_.append(dict['numberOfPlayers'])
    except:
        send_.append('-')
    try:
        send_.append(str(dict['eshoprating']))
    except:
        send_.append('-')
    try:
        send_.append(sq_tools.getSize(dict['InstalledSize']))
    except:
        send_.append('-')
    try:
        send_.append(BuildID8)
    except:
        send_.append('-')
    try:
        send_.append(ModuleId)
    except:
        send_.append('-')
    try:
        send_.append(dict['key'])
    except:
        send_.append('-')
    try:
        send_.append(RSV_rq_min[1:-1])
    except:
        send_.append('-')
    if 'regions' in dict:
        reg = str((', '.join(dict['regions'])))
        send_.append(reg)
    else:
        send_.append('-')
    try:
        if dict["intro"] != '-' and dict["intro"] != None and dict[
                "intro"] != '':
            if str(dict['Type']).upper() != 'DLC':
                send_.append(dict['baseName'] + ". " + dict["intro"])
            else:
                send_.append(dict['contentname'] + ". " + dict["intro"])
        else:
            if str(dict['Type']).upper() != 'DLC':
                send_.append(dict['baseName'])
            else:
                send_.append(dict['contentname'])
    except:
        if str(dict['Type']).upper() != 'DLC':
            try:
                send_.append(dict['baseName'])
            except:
                send_.append('-')
        else:
            try:
                send_.append(dict['contentname'])
            except:
                send_.append('-')
    try:
        if dict["description"] != '-':
            send_.append(dict["description"])
        else:
            send_.append("Not available")
    except:
        send_.append("Not available")
    try:
        if str(dict['HtmlManual']).lower() == "true":
            send_.append("Yes")
        else:
            send_.append("No")
    except:
        send_.append('-')
    try:
        # print(str(dict['linkedAccRequired']))
        if str(dict['linkedAccRequired']).lower() == "true":
            send_.append("Yes")
        else:
            send_.append("No")
    except:
        send_.append('-')
    try:
        if dict["ContentNumber"] != '-':
            if int(dict["ContentNumber"]) > 1:
                if 'ContentString' in dict:
                    send_.append(dict["ContentString"])
                else:
                    send_.append("Yes ({})".format(dict["ContentNumber"]))
            else:
                send_.append("No")
        else:
            send_.append("-")
    except:
        send_.append("-")
    try:
        if filename.endswith('.nsp') or filename.endswith(
                '.nsx') or filename.endswith('.nsz'):
            send_.append("Eshop")
        elif filename.endswith('.xci') or filename.endswith('.xcz'):
            send_.append("Gamecard")
        else:
            send_.append("-")
    except:
        send_.append("-")
    try:
        send_.append(sq_tools.getSize(dict['GCSize']))
    except:
        send_.append('-')
    try:
        x = get_screen_gallery(dict["bannerUrl"], dict["screenshots"])
        send_.append(x)
    except:
        send_.append("Not available")
    try:
        RQversion = 0
        if str(dict['Type']).upper() == 'DLC':
            if int(RGV) > 0:
                RQversion = str(RGV) + " -> Patch ({})".format(str(RS_number))
            else:
                RQversion = str(RGV) + " -> Application ({})".format(
                    str(RS_number))
        send_.append(RQversion)
    except:
        send_.append('-')
    f.flush()
    f.close()
    return send_
Exemple #4
0
def getinfo(filename):
	print('* Retrieving Game Information')
	if filename.endswith('.nsp')or filename.endswith('.nsx') or filename.endswith('.nsz'):
		f = Fs.ChromeNsp(filename, 'rb')
	elif filename.endswith('.xci') or filename.endswith('.xcz'):	
		f = Fs.ChromeXci(filename)		
	else: return []		
	dict=f.return_DBdict()
	try:
		ModuleId,BuildID8,BuildID16=f.read_buildid()	
		ModuleId=sq_tools.trimm_module_id(ModuleId)
	except:
		ModuleId="-";BuildID8="-";BuildID16="-";
	try:	
		MinRSV=sq_tools.getMinRSV(dict['keygeneration'],dict['RSV'])
		RSV_rq_min=sq_tools.getFWRangeRSV(MinRSV)
		FW_rq=sq_tools.getFWRangeKG(dict['keygeneration'])	
	except:
		MinRSV="-";RSV_rq_min="-";FW_rq="-"
	try:	
		RGV=dict['RGV']
		RS_number=int(int(RGV)/65536)
	except:
		RGV="0";RS_number="0";	
	send_=list()
	try:
		if str(dict['Type']).upper()=='DLC':
			send_.append(dict['contentname'])			
		else:
			send_.append(dict['baseName'])
	except:send_.append('-')
	try:
		send_.append(dict['editor'])
	except:send_.append('-')
	try:		
		send_.append(dict['id'])
	except:send_.append('-')
	try:			
		send_.append(dict['version'])	
	except:send_.append('-')
	try:			
		send_.append(dict['Type'])	
	except:send_.append('-')
	try:			
		send_.append(dict['dispversion'])	
	except:send_.append('-')
	try:
		send_.append(dict['metasdkversion'])
	except:send_.append('-')
	try:			
		send_.append(dict['exesdkversion'])	
	except:send_.append('-')
	try:			
		lang=str((', '.join(dict['languages'])))
		send_.append(lang)	
	except:send_.append('-')
	try:			
		send_.append(dict['RSV'])
	except:send_.append('-')
	try:			
		send_.append(str(dict['keygeneration'])+" -> " +FW_rq)				
	except:send_.append('-')
	try:	
		send_.append(dict['nsuId'])		
	except:send_.append('-')
	try:			
		genres=str((', '.join(dict['genretags'])))
		send_.append(genres)	
	except:send_.append('-')
	try:			
		ratags=str((', '.join(dict['ratingtags'])))
		send_.append(ratags)				
	except:send_.append('-')
	try:			
		send_.append(dict['worldreleasedate'])	
	except:send_.append('-')
	try:			
		send_.append(dict['numberOfPlayers'])	
	except:send_.append('-')
	try:			
		send_.append(str(dict['eshoprating']))	
	except:send_.append('-')
	try:			
		send_.append(sq_tools.getSize(dict['InstalledSize']))	
	except:send_.append('-')
	try:			
		send_.append(BuildID8)	
	except:send_.append('-')
	try:			
		send_.append(ModuleId)	
	except:send_.append('-')
	try:			
		send_.append(dict['key'])		
	except:send_.append('-')
	try:			
		send_.append(RSV_rq_min[1:-1])	
	except:send_.append('-')	
	if 'regions' in dict:
		reg=str((', '.join(dict['regions'])))
		send_.append(reg)
	else:
		send_.append('-')
	try:	
		if dict["intro"] !='-' and dict["intro"] !=None and dict["intro"] !='':
			if str(dict['Type']).upper()!='DLC':
				send_.append(dict['baseName']+". "+dict["intro"])	
			else:
				send_.append(dict['contentname']+". "+dict["intro"])
		else:
			if str(dict['Type']).upper()!='DLC':
				send_.append(dict['baseName'])	
			else:
				send_.append(dict['contentname'])				
	except:	
		if str(dict['Type']).upper()!='DLC':
			try:
				send_.append(dict['baseName'])	
			except:send_.append('-')	
		else:
			try:
				send_.append(dict['contentname'])
			except:send_.append('-')	
	try:	
		if dict["description"] !='-':		
			send_.append(dict["description"])
		else:
			send_.append("Not available")	
	except:send_.append("Not available")	
	try:			
		if str(dict['HtmlManual']).lower()=="true":
			send_.append("Yes")	
		else:
			send_.append("No")						
	except:send_.append('-')	
	try:			
		# print(str(dict['linkedAccRequired']))
		if str(dict['linkedAccRequired']).lower()=="true":
			send_.append("Yes")	
		else:
			send_.append("No")	
	except:send_.append('-')
	try:	
		if dict["ContentNumber"] !='-':		
			if int(dict["ContentNumber"])>1:
				if 'ContentString' in dict:
					send_.append(dict["ContentString"])
				else:
					send_.append("Yes ({})".format(dict["ContentNumber"]))
			else:	
				send_.append("No")			
		else:
			send_.append("-")	
	except:send_.append("-")		
	try:	
		if filename.endswith('.nsp')or filename.endswith('.nsx') or filename.endswith('.nsz'):
			send_.append("Eshop")	
		elif filename.endswith('.xci') or filename.endswith('.xcz'):
			send_.append("Gamecard")	
		else:		
			send_.append("-")			
	except:send_.append("-")
	try:
		send_.append(sq_tools.getSize(dict['GCSize']))	
	except:send_.append('-')	
	try:#data[30]
		x=get_screen_gallery(dict["bannerUrl"],dict["screenshots"])
		send_.append(x)			
	except:send_.append("Not available")
	try:#data[31]
		RQversion=0
		if str(dict['Type']).upper()=='DLC':
			if int(RGV)>0:
				RQversion=str(RGV)+" -> Patch ({})".format(str(RS_number))
			else:
				RQversion=str(RGV)+" -> Application ({})".format(str(RS_number))
		send_.append(RQversion)		
	except:send_.append('-')
	###NEW JSON STUFF###
	try:#data[32]			
		send_.append(dict['developer'])	
	except:send_.append('-')
	try:#data[33]			
		send_.append(dict['productCode'])	
	except:send_.append('-')
	try:#data[34]
		if str(dict['OnlinePlay']).lower()=="true":
			send_.append("Yes")	
		else:
			send_.append("No")						
	except:send_.append('No')
	try:#data[35]			
		if str(dict['SaveDataCloud']).lower()=="true":
			send_.append("Yes")	
		else:
			send_.append("No")						
	except:send_.append('No')
	try:#data[36]			
		playmodes=str((', '.join(dict['playmodes'])))
		send_.append(playmodes)	
	except:send_.append('-')
	try:#data[37]	
		if str(dict['metascore']).lower()=='false':
			send_.append('-')
		else:	
			send_.append(dict['metascore'])	
	except:send_.append('-')
	try:#data[38]			
		if str(dict['userscore']).lower()=='false':
			send_.append('-')
		else:		
			send_.append(dict['userscore'])	
	except:send_.append('-')
	try:#data[39]
		FWoncard=dict['FWoncard']
		FWoncard=str(FWoncard).strip("'")
		send_.append(FWoncard)	
	except:send_.append('-')
	try:#data[40]		
		if str(enablevideoplayback).lower() == 'true':
			video=dict['video']	
			video=ast.literal_eval(str(video))
			video=video[0]
			send_.append(str(video))	
		else:
			send_.append('-')
	except:send_.append('-')	
	try:#data[41]			
		if str(dict['openscore']).lower()=='false':
			send_.append('-')
		else:
			if dict['openscore'] != dict['metascore']:
				send_.append(dict['openscore'])	
			else:
				send_.append('-')
	except:send_.append('-')	
	f.flush()
	f.close()			
	return send_