diff --git a/oletools/ppt_parser.py b/oletools/ppt_parser.py index 450ded2..4d96bdd 100644 --- a/oletools/ppt_parser.py +++ b/oletools/ppt_parser.py @@ -15,6 +15,8 @@ References: # === LICENSE ================================================================= # TODO + + #------------------------------------------------------------------------------ # TODO: # - make stream optional in PptUnexpectedData @@ -22,14 +24,16 @@ References: # - license # - make buffered stream from output of iterative_decompress # - maybe can merge the 2 decorators into 1? (with_opened_main_stream) -# + + # CHANGELOG: # 2016-05-04 v0.01 CH: - start parsing "Current User" stream # 2016-07-20 v0.50 SL: - added Python 3 support # 2016-09-13 PL: - fixed olefile import for Python 2+3 # - fixed format strings for Python 2.6 (issue #75) +# 2017-04-23 v0.51 PL: - fixed absolute imports and issue #101 -__version__ = '0.50' +__version__ = '0.51dev6' # --- IMPORTS ------------------------------------------------------------------ @@ -39,11 +43,22 @@ import logging import struct import traceback import os - -import thirdparty.olefile as olefile - import zlib +# IMPORTANT: it should be possible to run oletools directly as scripts +# in any directory without installing them with pip or setup.py. +# In that case, relative imports are NOT usable. +# And to enable Python 2+3 compatibility, we need to use absolute imports, +# so we add the oletools parent folder to sys.path (absolute+normalized path): +_thismodule_dir = os.path.normpath(os.path.abspath(os.path.dirname(__file__))) +# print('_thismodule_dir = %r' % _thismodule_dir) +_parent_dir = os.path.normpath(os.path.join(_thismodule_dir, '..')) +# print('_parent_dir = %r' % _thirdparty_dir) +if not _parent_dir in sys.path: + sys.path.insert(0, _parent_dir) + +from oletools.thirdparty.olefile import olefile + # a global logger object used for debugging: log = olefile.get_logger('ppt') diff --git a/setup.py b/setup.py index bf0f5ec..afeae9b 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ import os, fnmatch #--- METADATA ----------------------------------------------------------------- name = "oletools" -version = '0.51dev4' +version = '0.51dev6' 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" long_desc = open('oletools/README.rst').read() author = "Philippe Lagadec"