Commit 0b652e8c48258d1e4e28b8fd7484faf9b423afd7

Authored by decalage2
1 parent 96de55c5

olevba: decompress_stream now accepts both bytes and bytearray (fixes #422)

oletools/olevba.py
@@ -215,8 +215,9 @@ from __future__ import print_function @@ -215,8 +215,9 @@ from __future__ import print_function
215 # 2019-01-01 PL: - removed support for Python 2.6 215 # 2019-01-01 PL: - removed support for Python 2.6
216 # 2019-03-18 PL: - added XLM/XLF macros detection for Excel OLE files 216 # 2019-03-18 PL: - added XLM/XLF macros detection for Excel OLE files
217 # 2019-03-25 CH: - added decryption of password-protected files 217 # 2019-03-25 CH: - added decryption of password-protected files
  218 +# 2019-04-09 PL: - decompress_stream accepts bytes (issue #422)
218 219
219 -__version__ = '0.54' 220 +__version__ = '0.54.1'
220 221
221 #------------------------------------------------------------------------------ 222 #------------------------------------------------------------------------------
222 # TODO: 223 # TODO:
@@ -1249,8 +1250,8 @@ def decompress_stream(compressed_container): @@ -1249,8 +1250,8 @@ def decompress_stream(compressed_container):
1249 """ 1250 """
1250 Decompress a stream according to MS-OVBA section 2.4.1 1251 Decompress a stream according to MS-OVBA section 2.4.1
1251 1252
1252 - compressed_container: string compressed according to the MS-OVBA 2.4.1.3.6 Compression algorithm  
1253 - return the decompressed container as a string (bytes) 1253 + compressed_container: bytearray or bytes compressed according to the MS-OVBA 2.4.1.3.6 Compression algorithm
  1254 + return the decompressed container as a bytes string
1254 """ 1255 """
1255 # 2.4.1.2 State Variables 1256 # 2.4.1.2 State Variables
1256 1257
@@ -1272,9 +1273,10 @@ def decompress_stream(compressed_container): @@ -1272,9 +1273,10 @@ def decompress_stream(compressed_container):
1272 # DecompressedChunkStart: The location of the first byte of the DecompressedChunk (section 2.4.1.1.3) within the 1273 # DecompressedChunkStart: The location of the first byte of the DecompressedChunk (section 2.4.1.1.3) within the
1273 # DecompressedBuffer (section 2.4.1.1.2). 1274 # DecompressedBuffer (section 2.4.1.1.2).
1274 1275
1275 - # Check the input is a bytearray: 1276 + # Check the input is a bytearray, otherwise convert it (assuming it's bytes):
1276 if not isinstance(compressed_container, bytearray): 1277 if not isinstance(compressed_container, bytearray):
1277 - raise TypeError('decompress_stream requires a bytearray as input') 1278 + compressed_container = bytearray(compressed_container)
  1279 + # raise TypeError('decompress_stream requires a bytearray as input')
1278 decompressed_container = bytearray() # result 1280 decompressed_container = bytearray() # result
1279 compressed_current = 0 1281 compressed_current = 0
1280 1282
setup.py
@@ -48,7 +48,7 @@ import os, fnmatch @@ -48,7 +48,7 @@ import os, fnmatch
48 #--- METADATA ----------------------------------------------------------------- 48 #--- METADATA -----------------------------------------------------------------
49 49
50 name = "oletools" 50 name = "oletools"
51 -version = '0.54' 51 +version = '0.54.1'
52 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" 52 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"
53 long_desc = open('oletools/README.rst').read() 53 long_desc = open('oletools/README.rst').read()
54 author = "Philippe Lagadec" 54 author = "Philippe Lagadec"