Commit 5e58cf5a548f21066f1a6521d5afca9d32e42a2c

Authored by Sébastien Larinier
1 parent 5645a94f

olevba compliant python3.5

oletools/oledir.py
... ... @@ -94,7 +94,7 @@ STATUS_COLORS = {
94 94  
95 95 if __name__ == '__main__':
96 96 # print banner with version
97   - print 'oledir %s - http://decalage.info/python/oletools' % __version__
  97 + print('oledir %s - http://decalage.info/python/oletools' % __version__)
98 98  
99 99 if os.name == 'nt':
100 100 colorclass.Windows.enable(auto_colors=True, reset_atexit=True)
... ... @@ -126,7 +126,7 @@ if __name__ == '__main__':
126 126 # TODO: oledir option to hexdump the raw direntries
127 127 # TODO: olefile should be less picky about incorrect directory structures
128 128  
129   - for id in xrange(len(ole.direntries)):
  129 + for id in range(len(ole.direntries)):
130 130 d = ole.direntries[id]
131 131 if d is None:
132 132 # this direntry is not part of the tree: either unused or an orphan
... ...
oletools/olevba.py
... ... @@ -2180,7 +2180,7 @@ class VBA_Parser(object):
2180 2180 if data is None:
2181 2181 data = open(filename, 'rb').read()
2182 2182 # check if it is a Word 2003 XML file (WordProcessingML): must contain the namespace
2183   - if 'http://schemas.microsoft.com/office/word/2003/wordml' in data:
  2183 + if b'http://schemas.microsoft.com/office/word/2003/wordml' in data:
2184 2184 self.open_word2003xml(data)
2185 2185 # store a lowercase version for the next tests:
2186 2186 data_lowercase = data.lower()
... ... @@ -2190,14 +2190,14 @@ class VBA_Parser(object):
2190 2190 # and even whitespaces in between "MIME", "-", "Version" and ":". The version number is ignored.
2191 2191 # And the line is case insensitive.
2192 2192 # so we'll just check the presence of mime, version and multipart anywhere:
2193   - if self.type is None and 'mime' in data_lowercase and 'version' in data_lowercase \
2194   - and 'multipart' in data_lowercase:
  2193 + if self.type is None and b'mime' in data_lowercase and b'version' in data_lowercase \
  2194 + and b'multipart' in data_lowercase:
2195 2195 self.open_mht(data)
2196 2196 #TODO: handle exceptions
2197 2197 #TODO: Excel 2003 XML
2198 2198 # Check if this is a plain text VBA or VBScript file:
2199 2199 # To avoid scanning binary files, we simply check for some control chars:
2200   - if self.type is None and '\x00' not in data:
  2200 + if self.type is None and b'\x00' not in data:
2201 2201 self.open_text(data)
2202 2202 if self.type is None:
2203 2203 # At this stage, could not match a known format:
... ...