outFolder = sys.argv[2] if len(sys.argv) >= 3 else defOutFolder offestStr = sys.argv[3] if len(sys.argv) >= 4 else defOffet sizeStr = sys.argv[4] if len(sys.argv) >= 5 else defSize #hwKey = sys.argv[5] if len(sys.argv) >= 6 else defKey offset = int(offestStr, 16) size = int(sizeStr, 16) # Create out directory print("[i] Create output directory") utils.createDirectory(outFolder) # Get the key bank section and store it outEncKeyBankFile = os.path.join(outFolder, 'key_bank.bin') print("[i] Save mstar key bank to {}".format(outEncKeyBankFile)) utils.copyPart(mboot, outEncKeyBankFile, offset, size) # Unpack the key bank to key bank structure print("[i] Unpack key bank structure") keyBankBytes = utils.loadPart(outEncKeyBankFile, 0, size) keyBank = utils.unpackStructure(CUSTOMER_KEY_BANK, keyBankBytes) if (DEBUG): # Print all print("[i] u8SecIdentify:\n{}".format( utils.hexString(keyBank.customer.u8SecIdentify))) print("[i] u32Num: 0x{:08x}".format(keyBank.customer.info.u32Num)) print("[i] u32Size: 0x{:08x}".format(keyBank.customer.info.u32Size)) print("[i] u8Signature:\n{}".format( utils.hexString(keyBank.customer.u8Signature)))
quit() if len(sys.argv) == 3: outputDirectory = sys.argv[2] else: outputDirectory = 'unpacked' # Create output directory utils.createDirectory(outputDirectory) # Find header script # Header size is 16KB # Non used part is filled by 0xFF print("[i] Analizing header ...") header = utils.loadPart(inputFile, 0, HEADER_SIZE) utils.copyPart(inputFile, os.path.join(outputDirectory, "~header"), 0, HEADER_SIZE) offset = header.find('\xff'.encode(encoding='iso-8859-1')) if offset != -1: headerScript = header[:offset].decode() headerScriptFound = True if not headerScriptFound: print("[!] Could not find header script!") quit() if DEBUG: print(headerScript) # Save the script print("[i] Saving header script to " +