Commit 5c9b328c79fc694ad19666b163ce6ce1a4804c22

Authored by Christian Herdtweck
1 parent 97990227

record_base: ignore [Document]SummaryInformation streams

Showing 1 changed file with 24 additions and 2 deletions
oletools/record_base.py
... ... @@ -89,6 +89,9 @@ ENTRY_TYPE2STR = {
89 89 ###############################################################################
90 90  
91 91  
  92 +SUMMARY_INFORMATION_STREAM_NAMES = ('\x05SummaryInformation',
  93 + '\x05DocumentSummaryInformation')
  94 +
92 95 class OleRecordFile(olefile.OleFileIO):
93 96 """ an OLE compound file whose streams have (mostly) record structure
94 97  
... ... @@ -101,7 +104,10 @@ class OleRecordFile(olefile.OleFileIO):
101 104  
102 105 @classmethod
103 106 def stream_class_for_name(cls, stream_name):
104   - """ helper for iter_streams, must be overwritten in subclasses """
  107 + """ helper for iter_streams, must be overwritten in subclasses
  108 +
  109 + will not be called for SUMMARY_INFORMATION_STREAM_NAMES
  110 + """
105 111 return OleRecordStream # this is an abstract class!
106 112  
107 113 def iter_streams(self):
... ... @@ -119,7 +125,11 @@ class OleRecordFile(olefile.OleFileIO):
119 125 'is stream of size {}'.format(direntry.size) if is_stream else
120 126 'no stream ({})'.format(ENTRY_TYPE2STR[direntry.entry_type])))
121 127 if is_stream:
122   - clz = self.stream_class_for_name(direntry.name)
  128 + if not is_orphan and \
  129 + direntry.name in SUMMARY_INFORMATION_STREAM_NAMES:
  130 + clz = OleSummaryInformationStream
  131 + else:
  132 + clz = self.stream_class_for_name(direntry.name)
123 133 yield clz(self._open(direntry.isectStart, direntry.size),
124 134 None if is_orphan else direntry.name)
125 135  
... ... @@ -194,6 +204,18 @@ class OleRecordStream(object):
194 204 self.__class__.__name__)
195 205  
196 206  
  207 +class OleSummaryInformationStream(OleRecordStream):
  208 + """ stream for \05SummaryInformation and \05DocumentSummaryInformation
  209 +
  210 + Do nothing so far. OleFileIO reads quite some info from this. For more info
  211 + see [MS-OSHARED] 2.3.3 and [MS-OLEPS] 2.21 and references therein.
  212 + """
  213 + def iter_records(self, fill_data=False):
  214 + """ yields nothing, stops at once """
  215 + return
  216 + yield
  217 +
  218 +
197 219 class OleRecordBase(object):
198 220 """ a record found in an OleRecordStream
199 221  
... ...