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