https://github.com/tim-weis/ovba
An Office VBA project parser written in 100% safe Rust.
https://github.com/tim-weis/ovba
parser
Last synced: 7 months ago
JSON representation
An Office VBA project parser written in 100% safe Rust.
- Host: GitHub
- URL: https://github.com/tim-weis/ovba
- Owner: tim-weis
- License: mit
- Created: 2020-08-13T12:25:10.000Z (almost 5 years ago)
- Default Branch: develop
- Last Pushed: 2024-12-02T19:52:37.000Z (7 months ago)
- Last Synced: 2024-12-02T20:18:34.636Z (7 months ago)
- Topics: parser
- Language: Rust
- Homepage:
- Size: 112 KB
- Stars: 7
- Watchers: 4
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - tim-weis/ovba - An Office VBA project parser written in 100% safe Rust. (Rust)
README
[](https://crates.io/crates/ovba)
[](https://docs.rs/ovba)
[](https://github.com/tim-weis/ovba/actions)An Office VBA project parser written in 100% safe Rust. This is an implementation of the [\[MS-OVBA\]: Office VBA File Format Structure](https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-ovba/575462ba-bf67-4190-9fac-c275523c75fc) protocol (Revision 9.1, published 2020-02-19).
## Motivation
Binary file format parsers have historically been an attractive target for attackers. A combination of complex code logic with frequently unchecked memory accesses have had them fall victim to remote code execution exploits many times over.
Rust is a reliable ally in addressing many of these security concerns, empowering this crate to deliver a safe parser implementation.
## Features
This library provides read-only access to VBA projects' metadata and source code. Notable features include:
* Extract source code.
* Inspect metadata, like contained modules, references, etc.This library does not provide a way to extract the raw binary VBA project data from an Office document. This is the responsibility of client code. The companion [ovba-cli](https://github.com/tim-weis/ovba-cli) tool illustrates how this can be done.
## Usage
Write out all modules' source code:
```rust
use ovba::{open_project, Result};
use std::fs::{read, write};fn main() -> Result<()> {
let data = read("vbaProject.bin")?;
let project = open_project(data)?;for module in &project.modules {
let src_code = project.module_source_raw(&module.name)?;
write("./out/".to_string() + &module.name, src_code)?;
}Ok(())
}
```List all CFB entries contained in a VBA project:
```rust
use ovba::{open_project, Result};
use std::fs::read;fn main() -> Result<()> {
// Read raw project container
let data = read("vbaProject.bin")?;
let project = open_project(data)?;
// Iterate over CFB entries
for (name, path) in project.list()? {
println!(r#"Name: "{}"; Path: "{}""#, name, path);
}Ok(())
}
```## Backwards compatibility
At this time, both API and implementation are under development. It is expected to see breaking changes before reaching a 1.0 release. With 0.X.Y releases, breaking changes are signified by a bump in the 0.X version number, leaving non-breaking changes to a bump in the Y version number.
This is a preview release. It has been published to allow others to use it, and solicit feedback to help drive future decision.
## Future work
All future work is tracked [here](https://github.com/tim-weis/ovba/issues). Notable issues include:
* [Improve error reporting](https://github.com/tim-weis/issues/10).
If you are missing a feature, found a bug, have a question, or want to provide feedback, make sure to [file an issue](https://github.com/tim-weis/ovba/issues/new).