rust-strings
is a Rust library for extracting strings from binary data. \
It also have Python bindings.
Use the package manager pip to install rust-strings
.
bash
pip install rust-strings
rust-strings
is available on crates.io and can be included in your Cargo enabled project like this:
bash
[dependencies]
rust-strings = "0.1.0"
```python import rust_strings
ruststrings.strings(filepath="/bin/ls", min_length=3)
ruststrings.strings(filepath="/bin/ls", minlength=5, buffersize=1024)
ruststrings.strings(filepath=r"C:\Windows\notepad.exe", min_length=5, encodings=["utf-16le"])
ruststrings.strings(filepath=r"C:\Windows\notepad.exe", min_length=5, encodings=["ascii", "utf-16le"])
ruststrings.strings(bytes=b"test\x00\x00", minlength=4, encodings=["ascii"])
```
Full documentation available in docs.rs
```rust use ruststrings::{FileConfig, BytesConfig, strings, Encoding}; let config = FileConfig::new("/bin/ls").withminlength(5); let extractedstrings = strings(&config);
// Extract utf16le strings let config = FileConfig::new("C:\Windows\notepad.exe") .withminlength(15) .withencoding(Encoding::UTF16LE); let extractedstrings = strings(&config);
// Extract ascii and utf16le strings let config = FileConfig::new("C:\Windows\notepad.exe") .withminlength(15) .withencoding(Encoding::ASCII) .withencoding(Encoding::UTF16LE); let extracted_strings = strings(&config);
let config = BytesConfig::new(b"test\x00".tovec()); let extractedstrings = strings(&config); asserteq!(vec![(String::from("test"), 0)], extractedstrings.unwrap()); ```
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.