mirror of
https://github.com/xprism1/ntool.git
synced 2025-06-18 16:25:33 -04:00
ctr_cdn: add other titlekey passwords
This commit is contained in:
parent
bca15f126a
commit
a4e07b796a
@ -16,8 +16,46 @@ class CDNReader:
|
||||
self.tik_read = tikReader(tik, dev)
|
||||
self.titlekey = self.tik_read.titlekey
|
||||
else: # Use titlekey generation algorithm
|
||||
self.titlekey = hextobytes(CTR.titlekey_gen(self.tmd_read.titleID, 'mypass'))
|
||||
|
||||
if self.tmd_read.titleID[3:5] == '48':
|
||||
if self.tmd_read.titleID in [
|
||||
'000480044b424145',
|
||||
'000480044b474e4a',
|
||||
'000480044b4f514a',
|
||||
'000480044b524e45',
|
||||
'000480044b54394a',
|
||||
'000480044b594945',
|
||||
]:
|
||||
pw = '5037'
|
||||
elif self.tmd_read.titleID in [
|
||||
'00048005484e4443',
|
||||
'00048005484e444b',
|
||||
]:
|
||||
pw = 'redsst'
|
||||
else:
|
||||
pw = 'mypass'
|
||||
self.titlekey = hextobytes(CTR.titlekey_gen(self.tmd_read.titleID, pw))
|
||||
else:
|
||||
for i in self.content_files:
|
||||
for name, info in self.tmd_read.files.items():
|
||||
if name.split('.')[1] == i:
|
||||
file = (i, info['iv'])
|
||||
break
|
||||
|
||||
self.titlekey = b''
|
||||
for i in ['mypass', 'password', 'nintendo', 'redsst']:
|
||||
titlekey = hextobytes(CTR.titlekey_gen(self.tmd_read.titleID, i))
|
||||
cipher = AES.new(titlekey, AES.MODE_CBC, iv=file[1])
|
||||
with open(file[0], 'rb') as f:
|
||||
magic = cipher.decrypt(f.read(0x110))[0x100:0x104]
|
||||
try:
|
||||
if magic.decode('utf-8') == 'NCCH':
|
||||
self.titlekey = titlekey
|
||||
break
|
||||
except UnicodeDecodeError:
|
||||
continue
|
||||
if self.titlekey == b'':
|
||||
raise Exception('Could not generate valid titlekey')
|
||||
|
||||
def decrypt(self):
|
||||
for i in self.content_files:
|
||||
for name, info in self.tmd_read.files.items():
|
||||
|
14
utils.py
14
utils.py
@ -547,15 +547,19 @@ def cdn2cia(path, out='', title_ver='', cdn_dev=0, cia_dev=0):
|
||||
t = TMDReader(tmd)
|
||||
if out == '':
|
||||
out = f'{name}.{t.hdr.title_ver}.cia'
|
||||
if tik == '':
|
||||
tikBuilder(titleID=t.titleID, title_ver=t.hdr.title_ver, regen_sig=regen_sig, out='tik')
|
||||
tik = 'tik'
|
||||
|
||||
cdn = CDNReader(content_files=content_files, tmd=tmd, tik=tik, dev=cdn_dev)
|
||||
cdn = CDNReader(content_files=content_files, tmd=tmd, dev=cdn_dev)
|
||||
cdn.decrypt()
|
||||
cf = [i for i in os.listdir('.') if i.endswith('.ncch') or i.endswith('.nds')]
|
||||
|
||||
CIABuilder(content_files=cf, tik=tik, tmd=tmd, meta=1, dev=cia_dev, out='tmp.cia')
|
||||
if tik == '':
|
||||
tikBuilder(titleID=t.titleID, title_ver=t.hdr.title_ver, titlekey=hex(readbe(cdn.titlekey))[2:].zfill(32), regen_sig=regen_sig, out='tik')
|
||||
tik = 'tik'
|
||||
|
||||
meta = 1
|
||||
if t.titleID[3:5] == '48':
|
||||
meta = 0
|
||||
CIABuilder(content_files=cf, tik=tik, tmd=tmd, meta=meta, dev=cia_dev, out='tmp.cia')
|
||||
for i in cf:
|
||||
os.remove(i)
|
||||
if os.path.isfile('tik'):
|
||||
|
Loading…
Reference in New Issue
Block a user