from PIL import Image, ImageOps # Read the XORed binary data with open('./final.bin', 'rb') as f: data = f.read() # Interpret the 262,144 bytes as a 512x512 Grayscale image img = Image.frombytes('L', (512, 512), data) # The XOR differences might be very dark, so we auto-contrast it to make the flag pop img = ImageOps.autocontrast(img) # Save the final image img.save('the_armory.png') print("The forge is lit. Open the_armory.png")