From 0b652e8c48258d1e4e28b8fd7484faf9b423afd7 Mon Sep 17 00:00:00 2001 From: decalage2 Date: Tue, 9 Apr 2019 22:04:53 +0200 Subject: [PATCH] olevba: decompress_stream now accepts both bytes and bytearray (fixes #422) --- oletools/olevba.py | 12 +++++++----- setup.py | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/oletools/olevba.py b/oletools/olevba.py index e023ba1..7c4520d 100644 --- a/oletools/olevba.py +++ b/oletools/olevba.py @@ -215,8 +215,9 @@ from __future__ import print_function # 2019-01-01 PL: - removed support for Python 2.6 # 2019-03-18 PL: - added XLM/XLF macros detection for Excel OLE files # 2019-03-25 CH: - added decryption of password-protected files +# 2019-04-09 PL: - decompress_stream accepts bytes (issue #422) -__version__ = '0.54' +__version__ = '0.54.1' #------------------------------------------------------------------------------ # TODO: @@ -1249,8 +1250,8 @@ def decompress_stream(compressed_container): """ Decompress a stream according to MS-OVBA section 2.4.1 - compressed_container: string compressed according to the MS-OVBA 2.4.1.3.6 Compression algorithm - return the decompressed container as a string (bytes) + compressed_container: bytearray or bytes compressed according to the MS-OVBA 2.4.1.3.6 Compression algorithm + return the decompressed container as a bytes string """ # 2.4.1.2 State Variables @@ -1272,9 +1273,10 @@ def decompress_stream(compressed_container): # DecompressedChunkStart: The location of the first byte of the DecompressedChunk (section 2.4.1.1.3) within the # DecompressedBuffer (section 2.4.1.1.2). - # Check the input is a bytearray: + # Check the input is a bytearray, otherwise convert it (assuming it's bytes): if not isinstance(compressed_container, bytearray): - raise TypeError('decompress_stream requires a bytearray as input') + compressed_container = bytearray(compressed_container) + # raise TypeError('decompress_stream requires a bytearray as input') decompressed_container = bytearray() # result compressed_current = 0 diff --git a/setup.py b/setup.py index cb9c873..c5a044c 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ import os, fnmatch #--- METADATA ----------------------------------------------------------------- name = "oletools" -version = '0.54' +version = '0.54.1' desc = "Python tools to analyze security characteristics of MS Office and OLE files (also called Structured Storage, Compound File Binary Format or Compound Document File Format), for Malware Analysis and Incident Response #DFIR" long_desc = open('oletools/README.rst').read() author = "Philippe Lagadec" -- libgit2 0.21.4