Guest User

Nayuta Eboot Dump v1

a guest
Oct 25th, 2014
210
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Dump Nayuta eboot.
  2. # Need decrypted eboot in file boot.orig; outputs to ebootdump.csv
  3. # Many false positives.
  4.  
  5. import os
  6.  
  7. def get_data(filename):
  8.     totalbytes = os.path.getsize(filename)
  9.     infile = open(filename, 'rb')
  10.     totalfiledata = infile.read(totalbytes)
  11.     return totalfiledata
  12.  
  13. def is_jis_char(s):
  14.     try:
  15.         s.decode('cp932')
  16.     except UnicodeDecodeError:
  17.         return False
  18.     if len(s.decode('cp932')) == 1:
  19.         return True
  20.     return False
  21.  
  22. def filterspecialcodes(text):
  23.     textpos = 0
  24.     newtext = ""
  25.     specialflag = False
  26.  
  27.     while textpos < len(text):
  28.         if ord(text[textpos]) > 31 and ord(text[textpos]) < 128:
  29.             if specialflag == True:
  30.                 specialflag = False
  31.                 newtext += ' }'
  32.             newtext += text[textpos]
  33.             textpos += 1
  34.         elif is_jis_char(text[textpos:textpos+2]) and textpos + 1 != len(text):
  35.             if specialflag == True:
  36.                 specialflag = False
  37.                 newtext += ' }'
  38.             newtext += text[textpos:textpos+2]
  39.             textpos += 2
  40.         else:
  41.             if specialflag == False:
  42.                 specialflag = True
  43.                 newtext += '{'
  44.             newtext += ' ' + text[textpos].encode('hex')
  45.             textpos += 1
  46.            
  47.     if specialflag == True: newtext += ' }'
  48.  
  49.     return newtext    
  50.  
  51. global filedata
  52. filedata = get_data('boot.orig')
  53.  
  54. pos = 0x21d380
  55. flag = False
  56. output = ""
  57. output2 = ""
  58. while pos < 0x234680:
  59.     if (ord(filedata[pos]) > 31 and ord(filedata[pos]) < 128) \
  60.          or ord(filedata[pos]) == 0xA:
  61.         if flag == False:
  62.             addr = hex(pos)
  63.             startpos = pos
  64.         output2 += filedata[pos]
  65.         pos += 1
  66.         flag = True
  67.     elif is_jis_char(filedata[pos:pos+2]):
  68.         if flag == False:
  69.             addr = hex(pos)
  70.             startpos = pos
  71.         output2 += filedata[pos:pos+2]
  72.         pos += 2
  73.         flag = True
  74.     elif flag == True:
  75.         flag = False
  76.         if len(output2) > 1 and filedata[pos] == '\x00':
  77.             pos2 = pos
  78.             while filedata[pos2] == '\x00':
  79.                 pos2 += 1
  80.             avail_space = pos2 - startpos - 1
  81.             output += addr + '\t' + filterspecialcodes(output2) + \
  82.                       '\t' + str(avail_space) + '\r\n'
  83.         pos += 1
  84.         output2 = ""
  85.     else:
  86.         pos += 1
  87.  
  88. outfile = open('ebootdump.csv','wb')
  89. outfile.write(output)
  90. outfile.close()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×