Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Dump Nayuta eboot.
- # Need decrypted eboot in file boot.orig; outputs to ebootdump.csv
- # Many false positives.
- import os
- def get_data(filename):
- totalbytes = os.path.getsize(filename)
- infile = open(filename, 'rb')
- totalfiledata = infile.read(totalbytes)
- return totalfiledata
- def is_jis_char(s):
- try:
- s.decode('cp932')
- except UnicodeDecodeError:
- return False
- if len(s.decode('cp932')) == 1:
- return True
- return False
- def filterspecialcodes(text):
- textpos = 0
- newtext = ""
- specialflag = False
- while textpos < len(text):
- if ord(text[textpos]) > 31 and ord(text[textpos]) < 128:
- if specialflag == True:
- specialflag = False
- newtext += ' }'
- newtext += text[textpos]
- textpos += 1
- elif is_jis_char(text[textpos:textpos+2]) and textpos + 1 != len(text):
- if specialflag == True:
- specialflag = False
- newtext += ' }'
- newtext += text[textpos:textpos+2]
- textpos += 2
- else:
- if specialflag == False:
- specialflag = True
- newtext += '{'
- newtext += ' ' + text[textpos].encode('hex')
- textpos += 1
- if specialflag == True: newtext += ' }'
- return newtext
- global filedata
- filedata = get_data('boot.orig')
- pos = 0x21d380
- flag = False
- output = ""
- output2 = ""
- while pos < 0x234680:
- if (ord(filedata[pos]) > 31 and ord(filedata[pos]) < 128) \
- or ord(filedata[pos]) == 0xA:
- if flag == False:
- addr = hex(pos)
- startpos = pos
- output2 += filedata[pos]
- pos += 1
- flag = True
- elif is_jis_char(filedata[pos:pos+2]):
- if flag == False:
- addr = hex(pos)
- startpos = pos
- output2 += filedata[pos:pos+2]
- pos += 2
- flag = True
- elif flag == True:
- flag = False
- if len(output2) > 1 and filedata[pos] == '\x00':
- pos2 = pos
- while filedata[pos2] == '\x00':
- pos2 += 1
- avail_space = pos2 - startpos - 1
- output += addr + '\t' + filterspecialcodes(output2) + \
- '\t' + str(avail_space) + '\r\n'
- pos += 1
- output2 = ""
- else:
- pos += 1
- outfile = open('ebootdump.csv','wb')
- outfile.write(output)
- outfile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement