EDIT: THIS MESSAGE IS OUT DATE.
visit
http://mrobe.fan.googlepages.com/
for the latest version.
hi all,
a script that does everything for you!
it decrypts the file,
gets images by their number from m:robe, (then
you can change them).
use the updateimage function to upload them back. use CorrectCRC to render the new CRC, and Encrypt to create the final file.
use at your own risk!
(it works, i've managed to change some pictures, very cool).
if anyone has a good site where we can put this file let me know. meanwhile, you can just copy/paste this
python script, which does everything for you !
have fun,
shirour
mrobe500script.py:
------------------
Code:
# m:robe 500i image updater script - Ver 0.95 BETA
# -------------------------------------------------------------------
# Created by: shirour 29/04/06
# Usage:
#
# DISCLAIMER: USE THIS SCRIPT AT YOUR OWN RISK!
#
# DecryptFile(inputfile,outputfile)
# default inputfile = "N5002-BD.BIN"
# default outputfile = "N5002-BD.DEC"
#
# Decrypts the original firmware file (inverse it and reorder the bits)
#
# CorrectCRC(inputfile,outputfile):
#
# default inputfile = "N5002-BD.DEC"
# default outputfile = "N5002-BD.DEC"
#
# Updates the CRC according to the updated _DECRYPTED_(!) file.
#
# EncryptFile(inputfile,outputfile)
# default inputfile = "N5002-BD.BIN"
# default outputfile = "N5002-BD.DEC"
#
# Encrypts the updated firmware file (inverse it and reorder the bits)
#
# GetImage(imagenum,inputfile,offset):
# default inputfile = "N5002-BD.DEC"
# default offset = 0x100000-0x18 DO NOT CHANGE THIS VALUE!
#
# Reads the $imagenum$ (a number 0-389) from the decrypted
# firmware and saves it to a file named "imagenum.ext"
# (where the extension comes from the file type.
#
# UpdateImage(imagenum,imagefile,inputfile,outputfile,offset=0x100000-0x18):
# default inputfile = "N5002-BD.DEC"
# default outputfile = "N5002-BD.DEC"
# default offset = 0x100000-0x18 DO NOT CHANGE THIS VALUE!
#
# Updates the $imagenum$ image to $imagefile$.
#
# Normal usage scenario:
# put N5002-BD.BIN in the same directory as the script file.
# run DecryptFile()
# run GetImage(0) where here you can choose whatever image number you
# want, and do that as many times as you'd like...
# change the images, as long as their sizes don't grow.
# run CorrectCRC()
# run EncryptFile()
#
# have fun.
#
#
import binascii;
import array;
dec_dic = {
0:3,
1:2,
2:1,
3:0,
4:5,
5:6,
6:4,
7:7,
8:9,
9:11,
10:8,
11:10,
12:14,
13:12,
14:15,
15:13,
};
enc_dic = {}
for i in dec_dic:
enc_dic[dec_dic[i]] = i;
image_type_dic = {
'0x3E8L':'jpg',
'0x3E9L':'png',
};
def DecryptFile(inputfile="N5002-BD.BIN",outputfile="N5002-BD.DEC"):
ModifyFile(inputfile,outputfile,dec_dic);
def EncryptFile(inputfile="N5002-BD.DEC",outputfile="N5002-BD-NEW.BIN"):
ModifyFile(inputfile,outputfile,enc_dic);
def CorrectCRC(inputfile="N5002-BD.DEC",outputfile="N5002-BD.DEC"):
print "Opening file", inputfile;
inpfile = file(inputfile,"r+b",1000);
filearr = array.array('L', inpfile.read()).tolist() # make integer list
print "Computing the CRC..." #Note - the real file begins at 0x18 -> +5
CRC = reduce(lambda x,y:x+filearr[y+5],range(0,len(filearr)-5-1));
CRC = hex(CRC)[-9:-1];
print "The updated CRC value is:", CRC
inpfile.seek(0,0);
filearr = inpfile.read();
inpfile.close;
del inpfile;
print "Writing CRC to the file",outputfile
outfile = file(outputfile,"w+b",1000);
filearr=filearr[:-4];
for i in map(lambda x: dec_dic.get(x)-12,range(12,16)):
filearr = filearr+ chr(eval('0x'+CRC[2*i]+CRC[2*i+1]) ^ 0xFF);
outfile.write(filearr);
filearr = "";
outfile.close;
del outfile;
print "Done."
return CRC;
def ModifyFile(inputfile,outputfile,thedic):
print "Opening file", inputfile;
inpfile = file(inputfile,"r+b",1000);
filearr = array.array('B', inpfile.read()).tolist() # make integer list
tmplist = (len(filearr)/16+1)*range(0,16);
print "Reordering the file..."
filearr = map(lambda x:filearr[thedic[tmplist[x]]+(x/16)*16]^0xFF,range(0,len(filearr)));
print "Making output file",outputfile
outfile = file(outputfile,"w+b",1000);
filearr = map(lambda x:chr(x),filearr);
filearr = "".join(filearr);
outfile.write(filearr);
outfile.close;
inpfile.close;
tmplist = "";
print "Done."
return filearr;
def GetImage(imagenum,inputfile="N5002-BD.DEC",offset=0x100000-0x18):
if (imagenum > 389) or (imagenum <0> 389) or (imagenum < 0):
print "Wrong image number (0-389)";
return -1;
print "Reading input image file:",imagefile;
imgfile = file(imagefile,"r+b",1000);
imagestr = imgfile.read();
imgfile.close();
print "Reading input file:",inputfile;
inpfile = file(inputfile,"r+b",1000);
print "Extracting image details...";
adr_table = 0x50d84c;
inpfile.seek(adr_table+(imagenum)*4)
image_adr = array.array('L', inpfile.read(4)).tolist()[0];
inpfile.seek(image_adr-offset,0);
image_type = image_type_dic[hex(array.array('L', inpfile.read(8)).tolist()[0])];
image_max_size = array.array('L', inpfile.read(4)).tolist()[0];
image_adr = array.array('L', inpfile.read(4)).tolist()[0] - offset;
print "Checking image...";
if image_max_size < len(imagestr):
print "max image size:",image_max_size;
return -1;
imagestr = imagestr + (image_max_size-len(imagestr))*'\x00'; # add 00 if needed
inpfile.seek(0,0);
first_part = inpfile.read(image_adr);
inpfile.seek(image_adr+image_max_size,0);
second_part = inpfile.read();
final_file = first_part+imagestr+second_part;
inpfile.close();
print "Writing image file."
outfile = file(outputfile,"w+b",1000);
outfile.write(final_file);
outfile.close;
print "Done."
return image_adr;
[/code]