Commit 14dcbdca01a547f5c1670f31ee7d0056502359b7
1 parent
05a27a43
start integrating ppt_parser into olevba
Showing
1 changed file
with
35 additions
and
0 deletions
oletools/olevba.py
| ... | ... | @@ -302,6 +302,7 @@ TYPE_OpenXML = 'OpenXML' |
| 302 | 302 | TYPE_Word2003_XML = 'Word2003_XML' |
| 303 | 303 | TYPE_MHTML = 'MHTML' |
| 304 | 304 | TYPE_TEXT = 'Text' |
| 305 | +TYPE_PPT = 'PPT' | |
| 305 | 306 | |
| 306 | 307 | # short tag to display file types in triage mode: |
| 307 | 308 | TYPE2TAG = { |
| ... | ... | @@ -310,6 +311,7 @@ TYPE2TAG = { |
| 310 | 311 | TYPE_Word2003_XML: 'XML:', |
| 311 | 312 | TYPE_MHTML: 'MHT:', |
| 312 | 313 | TYPE_TEXT: 'TXT:', |
| 314 | + TYPE_PPT: 'PPT', | |
| 313 | 315 | } |
| 314 | 316 | |
| 315 | 317 | |
| ... | ... | @@ -2182,6 +2184,30 @@ class VBA_Parser(object): |
| 2182 | 2184 | % (self.filename, MSG_OLEVBA_ISSUES)) |
| 2183 | 2185 | pass |
| 2184 | 2186 | |
| 2187 | + def open_ppt(self, ole): | |
| 2188 | + """ try to interpret ole file as PowerPoint 97-2003 using PptParser """ | |
| 2189 | + try: | |
| 2190 | + ppt_parser = ppt_parser.PptParser(ole) | |
| 2191 | + n_infos = len(ppt_parser.search_vba_info()) | |
| 2192 | + storages = ppt_parser.search_vba_storage() | |
| 2193 | + n_storages = len(storages) | |
| 2194 | + log.debug('ppt: found {} infos and {} storages'.format(n_infos, | |
| 2195 | + n_storages)) | |
| 2196 | + if n_infos != n_storages: | |
| 2197 | + log.warning('ppt: found different number of vba infos and storages!') | |
| 2198 | + for storage in storages: | |
| 2199 | + if storage.is_compressed: | |
| 2200 | + storage_decomp = self.ole_file.decompress_vba_storage(storage) | |
| 2201 | + else: | |
| 2202 | + log.warning('just guessing here: decompressed storage = storage?') | |
| 2203 | + storage_decomp = storage.read_all() # not implemented yet | |
| 2204 | + self.ole_subfiles.append(VBA_Parser(None, storage_decomp, | |
| 2205 | + container='PptParser')) | |
| 2206 | + self.ole_file = None # required to make other methods look at ole_subfiles | |
| 2207 | + self.type = TYPE_PPT | |
| 2208 | + except Exception: | |
| 2209 | + log.exception('Failed PPT parsing for file %r' % self.filename) | |
| 2210 | + | |
| 2185 | 2211 | |
| 2186 | 2212 | def open_text(self, data): |
| 2187 | 2213 | """ |
| ... | ... | @@ -2224,6 +2250,15 @@ class VBA_Parser(object): |
| 2224 | 2250 | for each VBA project found if OLE file |
| 2225 | 2251 | """ |
| 2226 | 2252 | log.debug('VBA_Parser.find_vba_projects') |
| 2253 | + | |
| 2254 | + # if this is a ppt file (PowerPoint 97-2003): | |
| 2255 | + # let ppt_parser do its job | |
| 2256 | + if self.type == TYPE_PPT: | |
| 2257 | + self.vba_projects = [] | |
| 2258 | + for subfile in self.ole_subfiles: | |
| 2259 | + self.vba_projects.extend(subfile.find_vba_projects()) | |
| 2260 | + return self.vba_projects | |
| 2261 | + | |
| 2227 | 2262 | # if the file is not OLE but OpenXML, return None: |
| 2228 | 2263 | if self.ole_file is None: |
| 2229 | 2264 | return None | ... | ... |