Commit e07a649f95969697e7d0fd10ece15f8267bb534f
1 parent
a60d9f3e
created PptParser.read_vba_storage for uncompressed data storages
Showing
2 changed files
with
23 additions
and
2 deletions
oletools/olevba.py
| ... | ... | @@ -2218,8 +2218,7 @@ class VBA_Parser(object): |
| 2218 | 2218 | storage_decomp = ppt.decompress_vba_storage(storage) |
| 2219 | 2219 | n_compressed += 1 |
| 2220 | 2220 | else: |
| 2221 | - log.warning('just guessing here: decompressed storage = storage?') | |
| 2222 | - storage_decomp = storage.read_all() # not implemented yet | |
| 2221 | + storage_decomp = ppt.read_vba_storage_data(storage) | |
| 2223 | 2222 | self.ole_subfiles.append(VBA_Parser(None, storage_decomp, |
| 2224 | 2223 | container='PptParser')) |
| 2225 | 2224 | log.info('File is PPT with {} vba infos ({} with macros) and {} ' | ... | ... |
oletools/ppt_parser.py
| ... | ... | @@ -1490,6 +1490,28 @@ class PptParser(object): |
| 1490 | 1490 | stream.close() |
| 1491 | 1491 | |
| 1492 | 1492 | |
| 1493 | + def read_vba_storage_data(self, storage): | |
| 1494 | + """ return data pointed to by uncompressed storage """ | |
| 1495 | + | |
| 1496 | + log.debug('reading uncompressed VBA OLE data stream') | |
| 1497 | + stream = None | |
| 1498 | + try: | |
| 1499 | + log.debug('opening stream') | |
| 1500 | + stream = self.ole.openstream(MAIN_STREAM_NAME) | |
| 1501 | + | |
| 1502 | + log.debug('reading {} bytes starting at {}' | |
| 1503 | + .format(storage.data_size, storage.data_offset)) | |
| 1504 | + stream.seek(storage.data_offset, os.SEEK_SET) | |
| 1505 | + data = stream.read(storage.data_size) | |
| 1506 | + | |
| 1507 | + return data | |
| 1508 | + | |
| 1509 | + finally: | |
| 1510 | + if stream is not None: | |
| 1511 | + log.debug('closing stream') | |
| 1512 | + stream.close() | |
| 1513 | + | |
| 1514 | + | |
| 1493 | 1515 | def iterative_decompress(stream, size, chunk_size=4096): |
| 1494 | 1516 | """ decompress data from stream chunk-wise """ |
| 1495 | 1517 | ... | ... |