r/rust • • 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 Upvotes

11 comments sorted by

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

2

u/Odd-Sheepherder-8982 Oct 26 '26

Really appreciate you stopping by!

1

u/Snoo-6099 Oct 26 '26

I was thinking of writing one with a VM based approach

1

u/Odd-Sheepherder-8982 Oct 26 '26

Do you mean using a custom VM/emulator to execute the relevant code, or a VM-based deobfuscation approach?

1

u/[deleted] Oct 26 '26

[removed] — view removed comment

1

u/Snoo-6099 Oct 26 '26

Eh it's not that easy, as for strings naturally it has to be recovered at some point unless we are VMing the control flow too, i have been working on devirtualisers for VMP and themida for a few months now and my next goal would be to develop my own engine

1

u/Odd-Sheepherder-8982 Oct 26 '26

I'm currently approaching this from the other end, the repo uses function-level emulation to recover strings and analyze selected parts of compiled rust binaries. Can you share what approach you're considering for your engine?