Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. import struct
  2.  
  3. knowntids = open('knowntitleids.txt', 'rb').readlines()
  4. knowntids = [x.rstrip() for x in knowntids] #Remove line breaks
  5.  
  6. i = 0
  7. with open('nand.fat16.bin', 'rb') as fh:
  8.     while 1:
  9.         data = fh.read(4*1024)
  10.        
  11.         x = data.find('NCCH')
  12.         if x != -1:
  13.             foundpos = x + (i*4*1024)
  14.             #print 'Found NCCH at: ' + str(foundpos)
  15.             savedpos = fh.tell()
  16.            
  17.             fh.seek(foundpos + 0x18)
  18.             titleid = fh.read(8)
  19.             titleid = ''.join('%02X' % ord(x) for x in titleid[::-1])
  20.             if titleid[:4] == b'0004':
  21.                 if not titleid in knowntids:
  22.                     print titleid
  23.                     fh.seek(foundpos + 4)
  24.                     size = struct.unpack('<I', fh.read(4))[0] * 512
  25.                     if size < (128*1024*1024):
  26.                         fh.seek(foundpos - 0x100)
  27.                         with open(titleid + '.ncch', 'wb') as title:
  28.                             title.write(fh.read(size))
  29.            
  30.             fh.seek(savedpos)
  31.         i += 1
  32.        
  33.         if len(data) < (4*1024):
  34.             break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement