#SETTINGS filename = "NESTLE.DAT" logfile = "extract.log" log = 1 files = [] # DO NOT CHANGE BELOW THIS LINE import sys import struct def get_hex_int(s): return struct.unpack("=I",s)[0] def get_hex_short(s): return struct.unpack("=B",s)[0] print "Nesquik Extractor by Triton - Portugal-a-Programar.org" print "Extracts the contents of NESTLE.DAT found in Nestle games.\n" print "Searching for %s..." % (filename), fp = open(filename, "rb") if fp: print "done." else: print "not found..." print "Aborting..." sys.exit(1) print "Finding the TOC offset...", fp.seek(-8, 2) #8 bytes from the end end = fp.tell() print "done." toc = get_hex_int(fp.read(4)) len = get_hex_int(fp.read(4)) print "Found", len, "items in the archive." fp.seek(toc) while fp.tell() < end: adr = get_hex_short(fp.read(1)) #skip 1 byte fp.seek(+1, 1) files.append([fp.read(adr), get_hex_int(fp.read(4))]) if log: c = 0 log = open(logfile, "w") print "Writing log to %s..." % (logfile), log.write("FILENAME => OFFSET\n") log.write("--------------------\n") for i in files: c += 1 log.write("%s) " % (c)) log.write("%s => %i\n" % (i[0], i[1])) log.close() print "done." print "Extracting data from file...", fp.seek(0) i = 0 while (i <= len): res = open(files[i][0], "wb") print files[i][0] if i == len: sub = toc-files[i][1] else: sub = files[i+1][1]-files[i][1] data = fp.read(sub) res.write(data) res.close() i +=1 print "done." print i, "files extracted." sys.exit(0)