# ZIP files example 0.4b # more info: http://www.pkware.com/documents/casestudies/APPNOTE.TXT # note that with some archives like those created by Stuff-it on MacOSX is # not possible to use this script because they are wrongly built, practically # they set the comp_size and uncomp_size fields of the "Local file header" at # 0 and they set them only in the relative "Central directory structure" which # means that it's necesary to read this one first for extracting the files # contained in the local header... senseless and stupid # script for QuickBMS http://aluigi.org/papers.htm#quickbms get zip_filesize asize for offset = 0 < zip_filesize #idstring "PK\x03\x04" get PK_sign short # so it works also with modified ZIP files! get sign short if sign == 0x0403 # Local file header 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 name offset uncomp_size else if method == 8 ComType deflate elif method == 1 ComType unshrink elif method == 6 ComType explode elif method == 9 ComType deflate64 elif method == 12 ComType bzip2 elif method == 14 ComType lzmaefs elif method == 21 ComType XMemDecompress elif method == 64 ComType darksector elif method == 98 ComType ppmd else print "unsupported compression method %method%" cleanexit endif CLog name offset comp_size uncomp_size endif math offset += comp_size goto offset elif sign == 0x0806 # Archive extra data record get extra_len long getdstring extra extra_len elif sign == 0x0201 # Central directory structure get ver_made short get ver_need 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 get comm_len short get disknum short get int_attr short get ext_attr long get rel_offset long getdstring name name_len getdstring extra extra_len getdstring comment comm_len elif sign == 0x0505 # Digital Signature get sign_len long getdstring sign sign_len elif sign == 0x0606 # Zip64 end of central directory record get dir_record longlong get ver_made short get ver_need short get num_disk long get num_disk2 long get tot_entries longlong get tot_entries2 longlong get central_size longlong get central_offset longlong print "Error: zip64 extensible data sector not implemented, contact me" cleanexit elif sign == 0x0706 # Zip64 end of central directory locator get start_central long get end_central longlong get disks long elif sign == 0x0605 # End of central directory record get disk_num short get disk_start short get central_entries short get central_entries short get central_size long get central_offset long get comm_len short getdstring comment comm_len elif sign == 0x0807 # Data Descriptor get crc long get comp_size long get uncomp_size long elif sign == 0x3030 # disk spanning # nothing? else print "Error: unknown ZIP signature %sign% at offset %offset%" cleanexit endif savepos offset next