Commit 6d02dcee0d294cb6b3d08bf6b70c025cf14934ed

Authored by decalage2
1 parent 8f1f3b5c

olevba: added enable_logging to fix issue #154

Showing 2 changed files with 16 additions and 4 deletions
oletools/olevba.py
@@ -192,8 +192,9 @@ from __future__ import print_function @@ -192,8 +192,9 @@ from __future__ import print_function
192 # - added keywords for Mac-specific macros (issue #130) 192 # - added keywords for Mac-specific macros (issue #130)
193 # 2017-03-08 PL: - fixed absolute imports 193 # 2017-03-08 PL: - fixed absolute imports
194 # 2017-03-16 PL: - fixed issues #148 and #149 for option --reveal 194 # 2017-03-16 PL: - fixed issues #148 and #149 for option --reveal
  195 +# 2017-05-19 PL: - added enable_logging to fix issue #154
195 196
196 -__version__ = '0.51dev3' 197 +__version__ = '0.51dev8'
197 198
198 #------------------------------------------------------------------------------ 199 #------------------------------------------------------------------------------
199 # TODO: 200 # TODO:
@@ -347,6 +348,18 @@ def get_logger(name, level=logging.CRITICAL+1): @@ -347,6 +348,18 @@ def get_logger(name, level=logging.CRITICAL+1):
347 log = get_logger('olevba') 348 log = get_logger('olevba')
348 349
349 350
  351 +def enable_logging():
  352 + """
  353 + Enable logging for this module (disabled by default).
  354 + This will set the module-specific logger level to NOTSET, which
  355 + means the main application controls the actual logging level.
  356 + """
  357 + log.setLevel(logging.NOTSET)
  358 + # Also enable logging in the ppt_parser module:
  359 + ppt_parser.enable_logging()
  360 +
  361 +
  362 +
350 #=== EXCEPTIONS ============================================================== 363 #=== EXCEPTIONS ==============================================================
351 364
352 class OlevbaBaseException(Exception): 365 class OlevbaBaseException(Exception):
@@ -2522,7 +2535,6 @@ class VBA_Parser(object): @@ -2522,7 +2535,6 @@ class VBA_Parser(object):
2522 """ 2535 """
2523 2536
2524 log.info('Check whether OLE file is PPT') 2537 log.info('Check whether OLE file is PPT')
2525 - ppt_parser.enable_logging()  
2526 try: 2538 try:
2527 ppt = ppt_parser.PptParser(self.ole_file, fast_fail=True) 2539 ppt = ppt_parser.PptParser(self.ole_file, fast_fail=True)
2528 for vba_data in ppt.iter_vba_data(): 2540 for vba_data in ppt.iter_vba_data():
@@ -3317,7 +3329,7 @@ def main(): @@ -3317,7 +3329,7 @@ def main():
3317 3329
3318 logging.basicConfig(level=LOG_LEVELS[options.loglevel], format='%(levelname)-8s %(message)s') 3330 logging.basicConfig(level=LOG_LEVELS[options.loglevel], format='%(levelname)-8s %(message)s')
3319 # enable logging in the modules: 3331 # enable logging in the modules:
3320 - log.setLevel(logging.NOTSET) 3332 + enable_logging()
3321 3333
3322 # Old display with number of items detected: 3334 # Old display with number of items detected:
3323 # print '%-8s %-7s %-7s %-7s %-7s %-7s' % ('Type', 'Macros', 'AutoEx', 'Susp.', 'IOCs', 'HexStr') 3335 # print '%-8s %-7s %-7s %-7s %-7s %-7s' % ('Type', 'Macros', 'AutoEx', 'Susp.', 'IOCs', 'HexStr')
setup.py
@@ -41,7 +41,7 @@ import os, fnmatch @@ -41,7 +41,7 @@ import os, fnmatch
41 #--- METADATA ----------------------------------------------------------------- 41 #--- METADATA -----------------------------------------------------------------
42 42
43 name = "oletools" 43 name = "oletools"
44 -version = '0.51dev7' 44 +version = '0.51dev8'
45 desc = "Python tools to analyze security characteristics of MS Office and OLE files (also called Structured Storage, Compound File Binary Format or Compound Document File Format), for Malware Analysis and Incident Response #DFIR" 45 desc = "Python tools to analyze security characteristics of MS Office and OLE files (also called Structured Storage, Compound File Binary Format or Compound Document File Format), for Malware Analysis and Incident Response #DFIR"
46 long_desc = open('oletools/README.rst').read() 46 long_desc = open('oletools/README.rst').read()
47 author = "Philippe Lagadec" 47 author = "Philippe Lagadec"