Commit 1c84a13f658c979b0562228643ac57e20e2c9583
1 parent
e54c6656
ppt_parser: fixed absolute imports and issue #101
Showing
2 changed files
with
21 additions
and
6 deletions
oletools/ppt_parser.py
| ... | ... | @@ -15,6 +15,8 @@ References: |
| 15 | 15 | |
| 16 | 16 | # === LICENSE ================================================================= |
| 17 | 17 | # TODO |
| 18 | + | |
| 19 | + | |
| 18 | 20 | #------------------------------------------------------------------------------ |
| 19 | 21 | # TODO: |
| 20 | 22 | # - make stream optional in PptUnexpectedData |
| ... | ... | @@ -22,14 +24,16 @@ References: |
| 22 | 24 | # - license |
| 23 | 25 | # - make buffered stream from output of iterative_decompress |
| 24 | 26 | # - maybe can merge the 2 decorators into 1? (with_opened_main_stream) |
| 25 | -# | |
| 27 | + | |
| 28 | + | |
| 26 | 29 | # CHANGELOG: |
| 27 | 30 | # 2016-05-04 v0.01 CH: - start parsing "Current User" stream |
| 28 | 31 | # 2016-07-20 v0.50 SL: - added Python 3 support |
| 29 | 32 | # 2016-09-13 PL: - fixed olefile import for Python 2+3 |
| 30 | 33 | # - fixed format strings for Python 2.6 (issue #75) |
| 34 | +# 2017-04-23 v0.51 PL: - fixed absolute imports and issue #101 | |
| 31 | 35 | |
| 32 | -__version__ = '0.50' | |
| 36 | +__version__ = '0.51dev6' | |
| 33 | 37 | |
| 34 | 38 | |
| 35 | 39 | # --- IMPORTS ------------------------------------------------------------------ |
| ... | ... | @@ -39,11 +43,22 @@ import logging |
| 39 | 43 | import struct |
| 40 | 44 | import traceback |
| 41 | 45 | import os |
| 42 | - | |
| 43 | -import thirdparty.olefile as olefile | |
| 44 | - | |
| 45 | 46 | import zlib |
| 46 | 47 | |
| 48 | +# IMPORTANT: it should be possible to run oletools directly as scripts | |
| 49 | +# in any directory without installing them with pip or setup.py. | |
| 50 | +# In that case, relative imports are NOT usable. | |
| 51 | +# And to enable Python 2+3 compatibility, we need to use absolute imports, | |
| 52 | +# so we add the oletools parent folder to sys.path (absolute+normalized path): | |
| 53 | +_thismodule_dir = os.path.normpath(os.path.abspath(os.path.dirname(__file__))) | |
| 54 | +# print('_thismodule_dir = %r' % _thismodule_dir) | |
| 55 | +_parent_dir = os.path.normpath(os.path.join(_thismodule_dir, '..')) | |
| 56 | +# print('_parent_dir = %r' % _thirdparty_dir) | |
| 57 | +if not _parent_dir in sys.path: | |
| 58 | + sys.path.insert(0, _parent_dir) | |
| 59 | + | |
| 60 | +from oletools.thirdparty.olefile import olefile | |
| 61 | + | |
| 47 | 62 | |
| 48 | 63 | # a global logger object used for debugging: |
| 49 | 64 | log = olefile.get_logger('ppt') | ... | ... |
setup.py
| ... | ... | @@ -41,7 +41,7 @@ import os, fnmatch |
| 41 | 41 | #--- METADATA ----------------------------------------------------------------- |
| 42 | 42 | |
| 43 | 43 | name = "oletools" |
| 44 | -version = '0.51dev4' | |
| 44 | +version = '0.51dev6' | |
| 45 | 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 | 46 | long_desc = open('oletools/README.rst').read() |
| 47 | 47 | author = "Philippe Lagadec" | ... | ... |