r/ExploitDev • u/ogapexx • Aug 08 '26
Rust vs C++ for RE and Maldev?
Hey!
I've searched up this topic and don't see anything that isn't multiple years old. Given how popular and accepted Rust is now and with it having a fully ported winapi library now, are there any reasons to stick to learning C++ for RE and Maldev or are we no longer in the era of "only C++ is viable"? Is there anyone here who uses rust as opposed to C++ or has switched from C++ to rust that could give an insight?
23
Upvotes
8
u/Euphoric_Interest_84 Aug 08 '26
C / C++ are the bases, I mean you can find almost any technique to learn written in C, so it’s important.
Modern languages has some benefits like some of them are more stealth due to AVs does not have enough samples yet to learn from it.
Cool option Nim, its like C styles Python, pretty fast, native multi platform compiling. Its amazing.
Golang is pretty good but Runtime in the binary is pretty hard to hide, and to make a shellcode you have to do black magic with Donut.
Rust it’s cool I’m not fan of its syntax.
My options are Nim and C, then Go, last Rust.
3
u/UnreactiveBrainstem Aug 08 '26 edited Aug 09 '26
I personally hate Rust's syntax, and hate having to fight with the borrow checker - I'm not crazy about the additional artifacts that get bundled in with the binary either. I don't mind like how memory management is done in C as you get into weird branching scenarios. I don't mind C++ as you have some features to help deal with it, although having ownership tied to specific types either in the language or in the codebase is not really ideal since this just more overhead from and my codebase that I am going to mentally have to keep track of. On top of that, the build systems are just a constant headache especially when you want to build cross platform malware.
For me, I ended up going with Zig because of it's philosophy of "No hidden control flow", clear memory management patterns, compile-time code execution (useful for randomizing API hashses), and it's cross platform build system was a joy to use while doing maldev - the ability to easily use existing c code is also a plus, although rewriting existing tradecraft will teach you a lot about the language. Zig's error handling can embed IoCs but you can get around this by using a bit of comptime magic at the top level of your program to catch every single error in your program, generate the enum values and the server code to handle them - if your writing an implant. Whereas in Rust you just have to accept that these IoCs will be embedded in the binary no matter what you do. I have been developing a C2 for nearly 5-6 years. The agent has migrated from Rust, to C, to C++, and finally this year I scrapped the agent entirely to rebuild it from the ground up in Zig, and have no regrets. There was a learning curve initially but after that, adding existing and new tradecraft is fairly straightforward.
During my day job I'm not really involved with C2 dev, but am the sole engineer that designs an internal payload generation platform similar to Outflanks OST. The build system for that application uses Zig is well, although it is a custom fork.
1
u/Juzdeed Aug 08 '26
Rust is fine and might be better, due to little bit harder to reverse engineer. Golang might be even worse to reverse engineer.
1
u/samaxidervish Aug 09 '26
C++ gotta be the gold standard for the flexibility. I dont like rust’s syntax and it feels limiting.
0
u/NoBrick2672 Aug 08 '26
maldev=?