#!/usr/bin/env python3 # Parses and decrypts watermarks from Red Star OS 3.0. # Currently supports only image watermarks. import sys import struct try: from Crypto.Cipher import DES except ImportError: print('Run: pip install pycrypto') sys.exit(1) KEY = b'\x07\x06\x05\x04\x03\x02\x01\x00' def wm_decrypt(wm): c = DES.new(KEY, DES.MODE_ECB) return c.decrypt(wm) if __name__ == '__main__': f = open(sys.argv[1], 'rb') f.seek(-3, 2) if f.read(3) != b'EOF': print('File does not include a watermark') sys.exit(1) f.seek(-7, 2) # The total length of the watermarks is # a 32 Bit little endian integer right # before the 'EOF' sequence. size = struct.unpack('