oletools is a Python package providing a collection of tools to analyze Microsoft Office and OLE (Object Linking and Embedding) files, also known as Structured Storage or Compound Document File Format. It's primarily used for malware analysis and incident response (DFIR). The current version is 0.60.2, with an active release cadence focused on bug fixes and new detection capabilities.
pip install oletoolsVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use `olevba` to detect and analyze VBA macros in a (dummy) OLE file. In a real scenario, `dummy_file_path` would point to an actual Office document. The `VBA_Parser` provides methods for macro detection, analysis, and extraction of suspicious keywords and IOCs. Remember to close the parser with `vbaparser.close()` to release file handles.
Upgrade to oletools v0.60.2 or newer when using Python 3.12.
Ensure `msoffcrypto-tool` is installed alongside `oletools` by running `pip install oletools[full]` or `pip install oletools msoffcrypto-tool lxml`.
Remove the '3' suffix from script calls (e.g., `olevba` instead of `olevba3`). Update any import paths that might have referred to these legacy versions.
Upgrade to oletools v0.60.2 or newer to ensure robust parsing of a wider range of potentially malicious OLE documents.
Install the package using pip: `pip install oletools` or `pip install -U oletools[full]` for all optional dependencies.
Ensure the input file is indeed a Microsoft Office document (pre-2007) or another OLE2 structured storage file. Verify the file type before processing, for instance, by checking its magic bytes or using `ftguess` (part of oletools) to identify its format.
This usually indicates an issue with the input file itself, such as a malformed document or a VBA stream that `olevba` cannot parse. While there's no direct code fix for the error in user space, reporting the specific file to the oletools developers can help improve parsing robustness. As a workaround, check if the VBA code extraction yielded `None` before attempting string operations.
Add the reported directory (e.g., `C:\Users\Daniel\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts` on Windows) to your system's PATH environment variable. Alternatively, you can run the scripts by providing their full path or by prefixing them with `python -m oletools.<tool_name>`, e.g., `python -m oletools.olevba`.