diff --git a/oletools/olevba.py b/oletools/olevba.py index aa87148..7fd3f9d 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 @@ -1770,13 +1775,13 @@ def json2ascii(json_obj, encoding='utf8', errors='replace'): # de-code and re-encode dencoded = json_obj.decode(encoding, errors).encode(encoding, errors) if dencoded != json_obj: - log.info('json2ascii: replaced: {0} (len {1})' + log.debug('json2ascii: replaced: {0} (len {1})' .format(json_obj, len(json_obj))) - log.info('json2ascii: with: {0} (len {1})' + log.debug('json2ascii: with: {0} (len {1})' .format(dencoded, len(dencoded))) return dencoded elif isinstance(json_obj, unicode): - log.info('json2ascii: replaced: {0}' + log.debug('json2ascii: encode unicode: {0}' .format(json_obj.encode(encoding, errors))) # cannot put original into logger # print 'original: ' json_obj