diff --git a/oletools/olevba.py b/oletools/olevba.py index aa87148..f72c05f 100755 --- a/oletools/olevba.py +++ b/oletools/olevba.py @@ -1417,122 +1417,127 @@ def _extract_vba(ole, vba_root, project_path, dir_path): unused = projectmodules_projectcookierecord_cookie log.debug("parsing {0} modules".format(projectmodules_count)) - for _ in xrange(0, projectmodules_count): - modulename_id = struct.unpack(" 0: - code_data = decompress_stream(code_data) - # case-insensitive search in the code_modules dict to find the file extension: - filext = code_modules.get(modulename_modulename.lower(), 'bin') - filename = '{0}.{1}'.format(modulename_modulename, filext) - #TODO: also yield the codepage so that callers can decode it properly - yield (code_path, filename, code_data) - # print '-'*79 - # print filename - # print '' - # print code_data - # print '' - log.debug('extracted file {0}'.format(filename)) - else: - log.warning("module stream {0} has code data length 0".format(modulestreamname_streamname)) - _ = unused + if section_id == 0x0047: + modulename_unicode_id = section_id + modulename_unicode_sizeof_modulename_unicode = struct.unpack(" 0: + code_data = decompress_stream(code_data) + # case-insensitive search in the code_modules dict to find the file extension: + filext = code_modules.get(modulename_modulename.lower(), 'bin') + filename = '{0}.{1}'.format(modulename_modulename, filext) + #TODO: also yield the codepage so that callers can decode it properly + yield (code_path, filename, code_data) + # print '-'*79 + # print filename + # print '' + # print code_data + # print '' + log.debug('extracted file {0}'.format(filename)) + else: + log.warning("module stream {0} has code data length 0".format(modulestreamname_streamname)) + except Exception as exc: + log.info('Error parsing module {} of {} in _extract_vba:' + .format(projectmodule_index, projectmodules_count), + exc_info=True) + _ = unused # make pylint happy: now variable "unused" is being used ;-) return