Commit 0b652e8c48258d1e4e28b8fd7484faf9b423afd7
1 parent
96de55c5
olevba: decompress_stream now accepts both bytes and bytearray (fixes #422)
Showing
2 changed files
with
8 additions
and
6 deletions
oletools/olevba.py
| ... | ... | @@ -215,8 +215,9 @@ from __future__ import print_function |
| 215 | 215 | # 2019-01-01 PL: - removed support for Python 2.6 |
| 216 | 216 | # 2019-03-18 PL: - added XLM/XLF macros detection for Excel OLE files |
| 217 | 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 | 223 | # TODO: |
| ... | ... | @@ -1249,8 +1250,8 @@ def decompress_stream(compressed_container): |
| 1249 | 1250 | """ |
| 1250 | 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 | 1256 | # 2.4.1.2 State Variables |
| 1256 | 1257 | |
| ... | ... | @@ -1272,9 +1273,10 @@ def decompress_stream(compressed_container): |
| 1272 | 1273 | # DecompressedChunkStart: The location of the first byte of the DecompressedChunk (section 2.4.1.1.3) within the |
| 1273 | 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 | 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 | 1280 | decompressed_container = bytearray() # result |
| 1279 | 1281 | compressed_current = 0 |
| 1280 | 1282 | ... | ... |
setup.py
| ... | ... | @@ -48,7 +48,7 @@ import os, fnmatch |
| 48 | 48 | #--- METADATA ----------------------------------------------------------------- |
| 49 | 49 | |
| 50 | 50 | name = "oletools" |
| 51 | -version = '0.54' | |
| 51 | +version = '0.54.1' | |
| 52 | 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 | 53 | long_desc = open('oletools/README.rst').read() |
| 54 | 54 | author = "Philippe Lagadec" | ... | ... |