|
|
|
@ -48,22 +48,24 @@ def encrypt_mks(source, target, env, new_name):
|
|
|
|
|
|
|
|
|
|
key = [0xA3, 0xBD, 0xAD, 0x0D, 0x41, 0x11, 0xBB, 0x8D, 0xDC, 0x80, 0x2D, 0xD0, 0xD2, 0xC4, 0x9B, 0x1E, 0x26, 0xEB, 0xE3, 0x33, 0x4A, 0x15, 0xE4, 0x0A, 0xB3, 0xB1, 0x3C, 0x93, 0xBB, 0xAF, 0xF7, 0x3E]
|
|
|
|
|
|
|
|
|
|
firmware = open(target[0].path, "rb")
|
|
|
|
|
renamed = open(target[0].dir.path + "/" + new_name, "wb")
|
|
|
|
|
length = os.path.getsize(target[0].path)
|
|
|
|
|
fwpath = target[0].path
|
|
|
|
|
fwfile = open(fwpath, "rb")
|
|
|
|
|
enfile = open(target[0].dir.path + "/" + new_name, "wb")
|
|
|
|
|
length = os.path.getsize(fwpath)
|
|
|
|
|
position = 0
|
|
|
|
|
try:
|
|
|
|
|
while position < length:
|
|
|
|
|
byte = firmware.read(1)
|
|
|
|
|
byte = fwfile.read(1)
|
|
|
|
|
if position >= 320 and position < 31040:
|
|
|
|
|
byte = chr(ord(byte) ^ key[position & 31])
|
|
|
|
|
if sys.version_info[0] > 2:
|
|
|
|
|
byte = bytes(byte, 'latin1')
|
|
|
|
|
renamed.write(byte)
|
|
|
|
|
enfile.write(byte)
|
|
|
|
|
position += 1
|
|
|
|
|
finally:
|
|
|
|
|
firmware.close()
|
|
|
|
|
renamed.close()
|
|
|
|
|
fwfile.close()
|
|
|
|
|
enfile.close()
|
|
|
|
|
os.remove(fwpath)
|
|
|
|
|
|
|
|
|
|
def add_post_action(action):
|
|
|
|
|
env.AddPostAction(join("$BUILD_DIR", "${PROGNAME}.bin"), action);
|
|
|
|
|