rust-strings
rust-strings
is a Rust library for extracting strings from binary data.
It also have Python bindings.
Installation
Python
Use the package manager pip to install rust-strings
.
Rust
rust-strings
is available on crates.io and can be included in your Cargo enabled project like this:
Usage
Python
# Get all ascii strings from file with minimun length of string
# [('ELF', 1),
# ('/lib64/ld-linux-x86-64.so.2', 680),
# ('GNU', 720),
# ('.<O', 725),
# ('GNU', 756),
# ...]
# You can also set buffer size when reading from file (default is 1mb)
# You can set encoding if you need (default is 'ascii', options are 'utf-16le', 'utf-16be')
# You can set multiple encoding
# You can also pass bytes instead of file_path
# [("test", 0)]
# You can also dump to json file
# `strings.json` content:
# [["test", 0]]
Rust
Full documentation available in docs.rs
use ;
use ;
let config = new.with_min_length;
let extracted_strings = strings;
// Extract utf16le strings
let config = new
.with_min_length
.with_encoding;
let extracted_strings = strings;
// Extract ascii and utf16le strings
let config = new
.with_min_length
.with_encoding
.with_encoding;
let extracted_strings = strings;
let config = new;
let extracted_strings = strings;
assert_eq!;
// Dump strings into `strings.json` file.
let config = new;
dump_strings;
Contributing
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.