Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Insert Nayuta eboot.
- # Need decrypted eboot in file boot.orig and ebootdump.csv w/ text to insert
- # ebootdump.csv: must be in tab-separated format. Cols beyond the 2nd are ignored
- # ebootdump.csv: must be saved with SHIFT-JIS encoding
- import os
- def get_data(filename):
- totalbytes = os.path.getsize(filename)
- infile = open(filename, 'rb')
- totalfiledata = infile.read(totalbytes)
- return totalfiledata
- def replacestr(origstr,replacestr,startpos,replacelen):
- #Returns a string with a replaced sub-string
- #origstr - the original string, replacestr = the string to replace
- #startpos - where the replacement string should go
- #replacelen - how many characters of the original string to replace
- return origstr[:startpos] + replacestr + origstr[startpos+replacelen:]
- def text_decode(text):
- while '{ ' in text:
- startpos = text.find('{ ')
- endpos = text.find(' }')
- s = text[startpos+1:endpos]
- s = s.translate(None,' ')
- s = s.decode('hex')
- text = text[:startpos] + s + text[endpos+2:]
- return text
- inputdata = []
- with open('ebootdump.csv','rb') as f:
- for line in f:
- line = line.translate(None,"\r\n") #Trims newline characters
- line = line.split('\t')
- addr = int(line[0],16)
- inputdata.append((addr,line[1]))
- filedata = get_data('boot.orig')
- for addr, text in inputdata:
- pos = filedata.find('\x00',addr)
- while filedata[pos] == '\x00':
- pos += 1
- avail_len = pos - addr - 1
- text = text_decode(text)
- if len(text) > avail_len:
- print "Text %s at address %s len is %d; max len is %d" \
- % (text, hex(addr), len(text), avail_len)
- text = text[:avail_len]
- text = text + (avail_len - len(text))*'\x00'
- filedata = replacestr(filedata,text,addr,avail_len)
- outfile = open('EBOOT.BIN','wb')
- outfile.write(filedata)
- outfile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement