Guest User

Nayuta Eboot Insert v1

a guest
Oct 25th, 2014
237
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Insert Nayuta eboot.
  2. # Need decrypted eboot in file boot.orig and ebootdump.csv w/ text to insert
  3. # ebootdump.csv: must be in tab-separated format. Cols beyond the 2nd are ignored
  4. # ebootdump.csv: must be saved with SHIFT-JIS encoding
  5.  
  6. import os
  7.  
  8. def get_data(filename):
  9.     totalbytes = os.path.getsize(filename)
  10.     infile = open(filename, 'rb')
  11.     totalfiledata = infile.read(totalbytes)
  12.     return totalfiledata
  13.  
  14. def replacestr(origstr,replacestr,startpos,replacelen):
  15. #Returns a string with a replaced sub-string
  16. #origstr - the original string, replacestr = the string to replace
  17. #startpos - where the replacement string should go
  18. #replacelen - how many characters of the original string to replace
  19.     return origstr[:startpos] + replacestr + origstr[startpos+replacelen:]
  20.  
  21. def text_decode(text):
  22.     while '{ ' in text:
  23.         startpos = text.find('{ ')
  24.         endpos = text.find(' }')
  25.         s = text[startpos+1:endpos]
  26.         s = s.translate(None,' ')
  27.         s = s.decode('hex')
  28.         text = text[:startpos] + s + text[endpos+2:]
  29.     return text
  30.  
  31. inputdata = []
  32. with open('ebootdump.csv','rb') as f:
  33.     for line in f:
  34.         line = line.translate(None,"\r\n") #Trims newline characters
  35.         line = line.split('\t')
  36.         addr = int(line[0],16)
  37.         inputdata.append((addr,line[1]))
  38.  
  39. filedata = get_data('boot.orig')
  40.  
  41. for addr, text in inputdata:
  42.     pos = filedata.find('\x00',addr)
  43.     while filedata[pos] == '\x00':
  44.         pos += 1
  45.     avail_len = pos - addr - 1
  46.     text = text_decode(text)
  47.     if len(text) > avail_len:
  48.         print "Text %s at address %s len is %d; max len is %d" \
  49.               % (text, hex(addr), len(text), avail_len)
  50.         text = text[:avail_len]
  51.     text = text + (avail_len - len(text))*'\x00'
  52.     filedata = replacestr(filedata,text,addr,avail_len)
  53.  
  54. outfile = open('EBOOT.BIN','wb')
  55. outfile.write(filedata)
  56. 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.

×