import base64 import re import zlib import subprocess import os import sys import binascii # Step 1: Prompt the user to input the .AAE file name file_path = input("Enter .AAE file name: ") # Ensure the file has a .AAE extension if not file_path.lower().endswith(".aae"): print("❌ Error: Input file must have a .AAE extension.") sys.exit() # Extract the base filename without extension and create output file name base_name = os.path.splitext(file_path)[0] output_plist = f"{base_name}.plist" # Step 2: Open and read the file try: with open(file_path, 'r', encoding='utf-8') as file: content = file.read() except FileNotFoundError: print("❌ The file was not found. Please check the file name and path and try again.") sys.exit() except Exception as e: print(f"❌ An error occurred: {e}") sys.exit() # Step 3: Extract Base64 data inside tags base64_data_match = re.search(r'(.*?)', content, re.DOTALL) if base64_data_match: base64_data = base64_data_match.group(1) # Step 4: Remove whitespaces (newlines, spaces, tabs) clean_base64 = re.sub(r'\s+', '', base64_data) try: # Step 5: Decode Base64 to binary binary_data = base64.b64decode(clean_base64) except binascii.Error as e: print(f"❌ Error during Base64 decoding: {e}") sys.exit() else: print("❌ No tag found in the AAE file.") sys.exit() # Step 6: Try zlib decompression, fallback to Base64 output if it fails try: decompressed_data = zlib.decompress(binary_data) print("✅ Standard zlib decompression successful.") except zlib.error: try: # Attempt raw deflate decompression (without zlib header) decompressed_data = zlib.decompress(binary_data, -15) print("✅ Raw deflate decompression successful using window size -15.") except zlib.error as e: print(f"⚠️ Decompression failed: {e}. Falling back to Base64-decoded data.") decompressed_data = binary_data # Step 7: Save the data (decompressed or base64-decoded) as '{name}.plist' with open(output_plist, 'wb') as output_file: output_file.write(decompressed_data) print(f"✅ Data saved as {output_plist}") # Step 8: Convert '{name}.plist' to XML plist format def convert_plist_to_xml(plist_file): try: subprocess.run(["plutil", "-convert", "xml1", plist_file], check=True) print(f"✅ Successfully converted {plist_file} to XML format.") except subprocess.CalledProcessError as e: print(f"❌ Error converting plist: {e}") if __name__ == "__main__": convert_plist_to_xml(output_plist)