#security #forensic-analysis #design #s-string

sanitation

tool for developing memory-safe programs while detecting and capturing possibly malicious bytes

4 releases (2 stable)

Uses new Rust 2024

1.0.1 Mar 21, 2025
1.0.0 Feb 18, 2025
0.0.1 Oct 27, 2023
0.0.0 Oct 27, 2023

#22 in #design

Download history 16/week @ 2024-12-07 4/week @ 2024-12-14 2/week @ 2025-02-01 4/week @ 2025-02-08 112/week @ 2025-02-15 18/week @ 2025-02-22 14/week @ 2025-03-01 10/week @ 2025-03-08 108/week @ 2025-03-15 107/week @ 2025-03-22

239 downloads per month
Used in 6 crates (2 directly)

GPL-3.0-or-later

31KB
512 lines

sanitation

Tool for developing memory-safe programs while detecting and capturing possibly malicious bytes.

Basic Design

Structs within the sanitation crate provide a garbage() method which returns potentially malicious bytes or covert communication channels.

Putting it simply, this crate serves as an effective tool to convert streams of bytes into valid strings while providing ways to check whether seeming garbage bytes might actually characterize exploits or covert communication channels, empowering developers and programs, for instance, to kill unwanted connections, insecure connections or even poorly-secured connections.

cargo add sanitation

Example

use sanitation::{to_hex, Error, SString};

fn main() -> Result<(), Error<'static>> {
    let data = [
        0x54, 0x68, 0x65, 0x20, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x6e,
        0x20, 0x66, 0x6f, 0x78, 0x20, 0x6a, 0x75, 0x6d, 0x70, 0x73, 0x20, 0x6f, 0x76, 0x65, 0x72,
        0x20, 0x74, 0x68, 0x65, 0x20, 0x6c, 0x61, 0x7a, 0x79, 0x20, 0x64, 0x6f, 0x67, 0xf4, 0xf1,
        0xf2, 0xf3,
    ];
    let sstring = SString::new(&data);
    println!("UTF-8 Safe String:\t{}", sstring.unchecked_safe());
    println!("Non-valid UTF-8 bytes:\t{}", to_hex(&sstring.garbage()));
    Ok(())
}

No runtime deps