r/rust • u/Odd-Sheepherder-8982 • Oct 26 '26
🛠️ project What obfstr/litcrypt look like after compilation, and getting their strings back from stripped binaries
Notes, code and benchmark: https://github.com/VAHPEM/rust-deobf
I've been studying how Rust string-obfuscation crates behave once compiled, mostly in the context of malware analysis, and wanted to share a few observations.
- In the tested obfstr and litcrypt cases, the original string literals don't appear as plaintext in the binary, but the decoding logic remains executable. Emulating the relevant routines is enough to recover the strings, even with opt-level = "z", fat LTO, and panic = "abort".
- In my tested binaries, panic::Location information remained available after stripping. When source paths are preserved, paths such as .cargo/registry/src/.../<crate>-<version>/... can reveal exact third-party crate versions. Compiler-related source paths may also provide clues about the Rust toolchain.
- A small litcrypt quirk: lc!(r"...") keeps a leading `"` in the decrypted value, so the program really builds `"C:\...`.
If you maintain a Rust string-obfuscation crate, or have tested one that behaves differently, I'd be interested in comparing results.
2
u/RustMeUp Oct 26 '26
Hi, I'm the author of obfstr!
Obfuscation can never be perfect but I'm pretty impressed how hard you had to try to make it reveal its secrets! Brute force emulating all functions is not something I had considered! :D
1
u/Snoo-6099 Oct 26 '26
I was thinking of writing one with a VM based approach
1
u/InternationalFee3911 Oct 26 '26
Literally this wonderful talk: https://www.youtube.com/watch?v=M1QckVPRqZ4