Commit 4984d587429dec8aa6511e7f1bc8f1e23f8e6a9e

Authored by Sébastien Larinier
1 parent 59215a07

fixed mht cases to compliant python3.5 in olevba

Showing 1 changed file with 5 additions and 2 deletions
oletools/olevba.py
@@ -404,7 +404,7 @@ TYPE2TAG = { @@ -404,7 +404,7 @@ TYPE2TAG = {
404 404
405 405
406 # MSO files ActiveMime header magic 406 # MSO files ActiveMime header magic
407 -MSO_ACTIVEMIME_HEADER = 'ActiveMime' 407 +MSO_ACTIVEMIME_HEADER = b'ActiveMime'
408 408
409 MODULE_EXTENSION = "bas" 409 MODULE_EXTENSION = "bas"
410 CLASS_EXTENSION = "cls" 410 CLASS_EXTENSION = "cls"
@@ -2333,6 +2333,8 @@ class VBA_Parser(object): @@ -2333,6 +2333,8 @@ class VBA_Parser(object):
2333 """ 2333 """
2334 log.info('Opening MHTML file %s' % self.filename) 2334 log.info('Opening MHTML file %s' % self.filename)
2335 try: 2335 try:
  2336 + if isinstance(data,bytes):
  2337 + data = data.decode('utf8', 'replace')
2336 # parse the MIME content 2338 # parse the MIME content
2337 # remove any leading whitespace or newline (workaround for issue in email package) 2339 # remove any leading whitespace or newline (workaround for issue in email package)
2338 stripped_data = data.lstrip('\r\n\t ') 2340 stripped_data = data.lstrip('\r\n\t ')
@@ -2362,7 +2364,8 @@ class VBA_Parser(object): @@ -2362,7 +2364,8 @@ class VBA_Parser(object):
2362 # using the ActiveMime/MSO format (zlib-compressed), and Base64 encoded. 2364 # using the ActiveMime/MSO format (zlib-compressed), and Base64 encoded.
2363 # decompress the zlib data starting at offset 0x32, which is the OLE container: 2365 # decompress the zlib data starting at offset 0x32, which is the OLE container:
2364 # check ActiveMime header: 2366 # check ActiveMime header:
2365 - if isinstance(part_data, str) and is_mso_file(part_data): 2367 +
  2368 + if (isinstance(part_data, str) or isinstance(part_data, bytes)) and is_mso_file(part_data):
2366 log.debug('Found ActiveMime header, decompressing MSO container') 2369 log.debug('Found ActiveMime header, decompressing MSO container')
2367 try: 2370 try:
2368 ole_data = mso_file_extract(part_data) 2371 ole_data = mso_file_extract(part_data)