If you didn’t know, rust keeps many “debug” strings in compiled binaries(for panic messages) (even on release with stripped symbols), there’s a couple of reasons why this might cause issues (especially for malware dev or when you wanna be stealthy)
- The strings contain your home directory by default (uh oh)
- They take space (grrr)
- Can become a detection vector
You can either replace your home dir prefix by something else if you don’t mind the strings being there or remove them completely.
How to “fix” the problem
Putting this in your .cargo/config file
[build]
rustflags = ["--remap-path-prefix", "C:\\Users\\yourusername=~"]
Changes your home dir to something else, but as you can see, the strings are still there.
How to actually FIX it
Compile with
[profile.release]
strip = true
# .. your other stuff here ..
panic = "abort"
and
cargo build -Zbuild-std -Zbuild-std-features=panic_immediate_abort --release
And voila! No panic messages! (and the bin went from 35kb to 20kb!) (also if you’re wondering why the strings looks mangled in IDA, rust doesn’t use null terminators)