# Castle Defenders (script 0.1a) # script for QuickBMS http://quickbms.aluigi.org math DO_COK6_TO_SWF = 1 for get EXT extension if EXT == "NREC" get NAME filename get SIZE asize log MEMORY_FILE 0 SIZE else ComType deflate get PK_sign short get sign short if PK_sign != 0x4b50 cleanexit endif if sign != 0x0403 cleanexit endif get get ver short get flag short get method short get modtime short get moddate short get crc long get comp_size long get uncomp_size long get name_len short get extra_len short getdstring name name_len getdstring extra extra_len savepos offset if method == 0 Log MEMORY_FILE offset uncomp_size else CLog MEMORY_FILE offset comp_size uncomp_size endif math offset += comp_size goto offset math SIZE = uncomp_size endif # create key from filename set MEMORY_FILE3 binary "\x1b\xbf\x18\xcc\x86\x5d\xf4\x25\x07\xc3\xe5\xb3\xb9\x04\x5a\x14\xd7\xfc\x4c\x86\x8d\x4a\xcb\x8f\x24\x53\x4a\x1e\xda\x06\x85\x5f\x7a\xc1\xb6\x8a\x76\x41\x20\xcb\x1f\xce\x61\xd6\xad\x74\x6b\x0f\x77\x82\x1e\x54\x89\xd7\x87\xb6\x05\xf9\x64\xcc\x57\x0b\xcf\x8b\xf8\xd2\x35\x80\x9c\xbf\x9e\x19\x5a\x8d\x84\x20\x6e\x90\xfb\x91\x1f\x48\xe0\xee\xc2\x03\xa2\xaf\x60\x2f\x93\xd6\xa8\x50\x2c\xe2" set MEMORY_FILE4 binary "\x08\x0A\x0C\x11\x01\x02\x0A\x0F\x00\x09\x0C\x10\x05\x06\x0B\x0E" strlen NAMELEN NAME string NAME u= NAME math NAME_CRC = 0 for i = 0 < NAMELEN getvarchr TMP NAME i math NAME_CRC *= 0x25 math NAME_CRC += TMP next i math EDX = SIZE math EDX /= 16 math EDX &= 0xf math TMP = EDX math TMP &= 3 math TMP *= 24 goto TMP MEMORY_FILE3 getdstring KEY 18 MEMORY_FILE3 math TMP = EDX math TMP /= 4 math TMP *= 4 goto TMP MEMORY_FILE4 getdstring TMP 4 MEMORY_FILE4 for i = 0 < 4 getvarchr POS TMP i putvarchr KEY POS NAME_CRC math NAME_CRC u>>= 8 next i encryption blowfish KEY "" 0 18 log MEMORY_FILE 0 SIZE MEMORY_FILE encryption "" "" math OFFSET = 0 set TMP extension NAME if TMP == "NREC" set NAME fullbasename NAME endif set TMP extension NAME if TMP == "COK6" # automatically convert COK6 to SWF if DO_COK6_TO_SWF != 0 set NAME fullbasename NAME string NAME += ".swf" goto 0x10 MEMORY_FILE get SIZE long MEMORY_FILE get OFFSET long MEMORY_FILE endif endif math SIZE -= OFFSET log NAME OFFSET SIZE MEMORY_FILE # useless because PAK archives contain only one file, but let's try the loop if EXT == "NREC" cleanexit endif next