14 releases (breaking)

0.13.1 Oct 2, 2024
0.13.0 Jul 17, 2024
0.12.1 Apr 12, 2023
0.12.0 Feb 13, 2023
0.6.0 Jun 15, 2021

#1432 in Network programming

Download history 2748/week @ 2024-07-27 1839/week @ 2024-08-03 1803/week @ 2024-08-10 2033/week @ 2024-08-17 2479/week @ 2024-08-24 2507/week @ 2024-08-31 2787/week @ 2024-09-07 2010/week @ 2024-09-14 2188/week @ 2024-09-21 2838/week @ 2024-09-28 3475/week @ 2024-10-05 3249/week @ 2024-10-12 2997/week @ 2024-10-19 3999/week @ 2024-10-26 2548/week @ 2024-11-02 1897/week @ 2024-11-09

11,818 downloads per month
Used in 12 crates (9 directly)

MIT license

19KB
349 lines

Français

Security Aware Wire Protocol parsing library.

This library contains parsers for various wire protocols, and is intended to be used in network security sensors.

Each parser exposes a common interface that allows the sensor engine to feed bytes into the parser and receive parsed metadata back. The bytes are expected to be at the session layer, so the engine is responsible for assembling transport layer data into a session payload, which is then fed into this library.

This library aims to be resilient and parse as many messages as possible that are seen in the wild. If a message is invalid or out-of-spec, it should not be discarded by the parser. Parsers will set flags on the message when it fails validation instead of returning an error.

The interface to each parser is uniform and simple, consisting of only a few functions to:

  • test that a payload is or is not the protocol in question (eg. is this modbus?)
  • provide more bytes to the parser
  • set callbacks to invoke on per-protocol metadata events (todo)
  • indicate that some bytes are unavailable (ie. notify of packet loss) (todo)
  • indicate a session has ended (todo)

The library exposes Rust and C bindings for easy integration into existing and future network security sensor platforms. (todo)

Usage

Start using SAWP by including a parser in your project's Cargo.toml dependencies. The base library will also be required for using common types.

The minimum supported version of rustc is 1.63.0.

Example

[dependencies]
sawp-modbus = "0.13.1"
sawp = "0.13.1"

FFI Support

Some parsers have a foreign function interface for use in C/C++ projects. FFI Support can be enabled by building with the ffi feature.

A Makefile is also provided to ease the build process. Please refer to this file for more in-depth documentation.

# Install cbindgen which is required to generate headers
cargo install --force cbindgen

# Build headers and shared objects
make

Contributing

This project is actively maintained and accepting open source contributions. See CONTRIBUTING for more details.

Dependencies

~0.5–1.1MB
~25K SLoC