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

sanitation

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

6 releases (stable)

new 1.0.3 Apr 13, 2025
1.0.2 Apr 8, 2025
1.0.1 Mar 21, 2025
1.0.0 Feb 18, 2025
0.0.1 Oct 27, 2023

#27 in #design

Download history 4/week @ 2025-02-02 3/week @ 2025-02-09 117/week @ 2025-02-16 12/week @ 2025-02-23 15/week @ 2025-03-02 10/week @ 2025-03-09 140/week @ 2025-03-16 83/week @ 2025-03-23 36/week @ 2025-03-30 311/week @ 2025-04-06

571 downloads per month
Used in 6 crates (via iocore)

MIT license

28KB
523 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