def searchUnpackLzip(filename, tempdir=None, blacklist=[], offsets={}, scanenv={}, debug=False):
hints = {}
if not 'lzip' in offsets:
return ([], blacklist, [], hints)
if offsets['lzip'] == []:
return ([], blacklist, [], hints)
filesize = os.stat(filename).st_size
if filesize < 5:
return ([], blacklist, [], hints)
diroffsets = []
tags = []
counter = 1
for offset in offsets['lzip']:
blacklistoffset = extractor.inblacklist(offset, blacklist)
if blacklistoffset != None:
continue
## sanity check, only versions 0 or 1 are supported
lzipfile = open(filename, 'rb')
lzipfile.seek(offset+4)
lzipversion = lzipfile.read(1)
lzipfile.close()
if struct.unpack('<B', lzipversion)[0] > 1:
continue
tmpdir = dirsetup(tempdir, filename, "lzip", counter)
(res, lzipsize) = unpackLzip(filename, offset, tmpdir)
if res != None:
diroffsets.append((res, offset, lzipsize))
blacklist.append((offset, offset+lzipsize))
counter = counter + 1
if offset == 0 and lzipsize == filesize:
tags.append("compressed")
tags.append("lzip")
else:
## cleanup
os.rmdir(tmpdir)
return (diroffsets, blacklist, tags, hints)
评论列表
文章目录