# Copyright (C) 2015 KillerInstinct, Optiv, Inc. (brad.spengler@optiv.com) # This file is part of Cuckoo Sandbox - http://www.cuckoosandbox.org # See the file 'docs/LICENSE' for copying permission. import os import struct import hashlib from binascii import crc32 import lib.cuckoo.common.office.olefile as olefile from lib.cuckoo.common.utils import store_temp_file def bytearray_xor(data, key): for i in range(len(data)): data[i] ^= key return data def read_trend_tag(data, offset): """ @return a code byte and data tuple """ code, length = struct.unpack(" binsize: binlen = binsize else: binlen = collectedsize bindata += data[offset+5+headerlen:offset+5+headerlen+binlen] has_header = False else: binlen = len(tagdata) collectedsize += binlen if collectedsize > binsize: binlen -= (collectedsize - binsize) bindata += data[offset+5:offset+5+binlen] else: if decode_next_container: extralen = 0 decode_next_container = False elif codeval == 0x10 or codeval == 0x8: if codeval == 0x8: xor_next_container = True lastlen = struct.unpack_from(" 15: return None dataoffset += 10 offset = 10 for i in range(numtags): code, tagdata = read_trend_tag(data, offset) if code == 1: # original pathname origpath = unicode(tagdata, encoding="utf16").encode("utf8", "ignore").rstrip("\0") elif code == 2: # original filename origname = unicode(tagdata, encoding="utf16").encode("utf8", "ignore").rstrip("\0") elif code == 3: # platform platform = str(tagdata) elif code == 4: # file attributes attributes = struct.unpack("