Commit 3287766170384d716dd8dcabbd70ae4ea78c6818

Authored by Christian Herdtweck
1 parent 73ed5d71

fix/clarify some output and add a comment

Showing 1 changed file with 9 additions and 3 deletions
oletools/olevba.py
... ... @@ -1515,7 +1515,7 @@ def _extract_vba(ole, vba_root, project_path, dir_path, relaxed=False):
1515 1515 vba_codec = 'cp%d' % projectcodepage_codepage
1516 1516 log.debug("ModuleName = {0}".format(modulename_modulename))
1517 1517 log.debug("ModuleNameUnicode = {0}".format(uni_out(modulename_unicode_modulename_unicode)))
1518   - log.debug("StreamName = {0}".format(uni_out(modulestreamname_streamname)))
  1518 + log.debug("StreamName = {0}".format(modulestreamname_streamname))
1519 1519 streamname_unicode = modulestreamname_streamname.decode(vba_codec)
1520 1520 log.debug("StreamName.decode('%s') = %s" % (vba_codec, uni_out(streamname_unicode)))
1521 1521 log.debug("StreamNameUnicode = {0}".format(uni_out(modulestreamname_streamname_unicode)))
... ... @@ -1526,13 +1526,15 @@ def _extract_vba(ole, vba_root, project_path, dir_path, relaxed=False):
1526 1526 modulename_unicode_modulename_unicode, \
1527 1527 modulestreamname_streamname_unicode
1528 1528 for stream_name in try_names:
  1529 + # TODO: if olefile._find were less private, could replace this
  1530 + # try-except with calls to it
1529 1531 try:
1530 1532 code_path = vba_root + u'VBA/' + stream_name
1531 1533 log.debug('opening VBA code stream %s' % uni_out(code_path))
1532 1534 code_data = ole.openstream(code_path).read()
1533 1535 break
1534 1536 except IOError as ioe:
1535   - log.debug('failed to open stream {} ({}), try other name'
  1537 + log.debug('failed to open stream VBA/{} ({}), try other name'
1536 1538 .format(uni_out(stream_name), ioe))
1537 1539  
1538 1540 if code_data is None:
... ... @@ -2507,7 +2509,11 @@ class VBA_Parser(object):
2507 2509 try:
2508 2510 data = ole._open(d.isectStart, d.size).read()
2509 2511 log.debug('Read %d bytes' % len(data))
2510   - log.debug(repr(data))
  2512 + if len(data) > 200:
  2513 + log.debug('{}...[much more data]...{}'
  2514 + .format(repr(data[:100]), repr(data[-50:])))
  2515 + else:
  2516 + log.debug(repr(data))
2511 2517 if 'Attribut' in data:
2512 2518 log.debug('Found VBA compressed code')
2513 2519 self.contains_macros = True
... ...