oletools_rs
Rust port of python-oletools — a set of tools for analyzing Microsoft Office files to detect VBA macros, DDE exploits, embedded objects, and other potentially malicious content.
Modules
| Module | Description |
|---|---|
| ole | OLE2 Compound Document parsing (streams, metadata, CLSIDs, timestamps) |
| ooxml | Office Open XML parsing (ZIP + XML parts, content types, relationships) |
| vba | VBA macro extraction and analysis (MS-OVBA decompression, keyword scanning) |
| ftguess | File type detection via magic bytes, OLE CLSID, and OOXML content types |
| mraptor | MacroRaptor heuristic detection of malicious macros (AutoExec + Write/Execute) |
| oleid | Security indicator analysis (format, encryption, VBA, mraptor, external rels, ObjectPool, Flash) |
| oleobj | Embedded OLE object extraction (OLE 1.0, OleNativeStream, external relationships) |
| rtfobj | RTF parsing and OLE extraction with CVE detection (CVE-2017-0199, CVE-2017-11882) |
| msodde | DDE command detection across .doc, .docx, .xls, .xlsx, RTF, CSV |
| oletimes | Timestamp extraction from OLE entries (FILETIME conversion) |
| crypto | Encrypted document detection (feature-gated) |
MSRV
Minimum Supported Rust Version: 1.87 (edition 2024).
Installation
[]
= "0.1"
To enable encrypted document support:
[]
= { = "0.1", = ["crypto"] }
Quick start
Detect file type
use FileTypeGuesser;
Extract VBA macros
use VbaParser;
Detect malicious macros (MacroRaptor)
use MacroRaptor;
Run full security analysis (OleID)
use OleID;
Extract OLE objects from RTF
use RtfObjParser;
Detect DDE commands
use msodde;
Extract timestamps
use oletimes;
Feature flags
| Flag | Default | Description |
|---|---|---|
crypto |
off | Enable encrypted document detection via office-crypto |
Project structure
src/
lib.rs Public API and re-exports
error.rs Unified error types (thiserror)
common/
codepages.rs Windows codepage to encoding_rs mapping
patterns.rs IOC regex patterns (URLs, IPs, executables)
ole/
container.rs OLE2 container (cfb wrapper)
clsid.rs Known CLSID database
metadata.rs OLE metadata extraction
directory.rs Directory entry types
sector_map.rs Sector chain analysis
ooxml/
parser.rs ZIP-based OOXML parser
content_types.rs [Content_Types].xml parser
relationships.rs .rels parser, external relationship detection
vba/
decompressor.rs MS-OVBA 2.4.1 decompression
project.rs VBA project dir stream parser
module.rs VBA module source extraction
parser.rs High-level VBA parser (OLE/OOXML/FlatOPC)
scanner.rs Suspicious pattern scanner
keywords.rs AutoExec/Suspicious keyword database
ftguess/
detector.rs File type detection engine
types.rs FileType, Container, Application enums
mraptor/
analyzer.rs MacroRaptor A/W/X heuristic engine
oleid/
indicator.rs Indicator and RiskLevel types
checker.rs 7-check security analysis
oleobj/
native_stream.rs OleNativeStream parser (MS-OLEDS 2.3.6)
ole_object.rs OLE 1.0 object parser
extractor.rs High-level embedded object extractor
rtfobj/
parser.rs RTF state machine parser
object.rs OLE object extraction from RTF
cve.rs CVE-2017-0199 / CVE-2017-11882 detection
msodde/
field_parser.rs DDE field types, QUOTE decoding, safe-field blocklist
doc.rs Word binary (.doc) DDE scanning
docx.rs Word OOXML (.docx) DDE scanning
xls.rs Excel binary (.xls) SupBook DDE scanning
xlsx.rs Excel OOXML (.xlsx) ddeLink scanning
rtf.rs RTF fldinst DDE scanning
csv.rs CSV formula injection detection
oletimes/
mod.rs FILETIME conversion and timestamp extraction
crypto/
mod.rs Encryption detection (feature-gated)
Testing
Disclaimer
This library is intended for defensive security analysis, malware triage, and forensic investigation. It parses and inspects Office documents but does not execute any embedded code. The detection heuristics (MacroRaptor, DDE, CVE checks) are indicators, not guarantees — always combine with other tools for production security decisions.