Why Rust or Offensive Rust

Posted on Jan 21, 2023

Why Rust or Offensive Rust?

This post briefly covers why I think Rust is a good programming language in general or for offensive purposes. I’m not a professional developer and only know some things, but I hope it helps someone. If you have not seen my GitHub PoCs then feel free to checkout my GitHub: https://github.com/memN0ps and/or trickster0’s https://github.com/trickster0/OffensiveRust

IMHO:

Open-Source Learning Resource:

  • Rust Programming Book: A comprehensive resource for learning Rust with a free online book: Rust Programming Book

Documentation and Learning:

  • Rust by Example: Well-structured and easily generated documentation: Rust by Example

Community:

Unit Testing:

Error Handling:

Memory Safety:

Performance:

  • Rust Performance: Explore Rust’s speed and power compared to other languages: Rust Performance

Full-Stack Development:

  • Full-Stack Rust: Discover a comprehensive tutorial and examples for full-stack Rust development: Full-Stack Rust Tutorial

Binary Reverse Engineering:

File Size and Optimization:

Compiler and Package Manager:

Crates and Dependencies:

More information:

Full-Stack Development in Rust

A list of useful crates for both low-level and high-level programming in Rust. For more information visit: https://github.com/stars/memN0ps/lists/rust

Main:

Other:

Offensive Rust Courses/Training/Books

Kernel Programming in Rust

Windows API Crates

  1. The official Microsoft repository has two crates, windows-rs and windows-sys https://github.com/microsoft/windows-rs. The one you use mostly depends on preferences. Check out the FAQ https://github.com/microsoft/windows-rs/blob/master/docs/FAQ.

  2. This is made by an individual named @retep998 https://github.com/retep998/winapi-rs and existed before Microsoft started supporting programming for Windows API in Rust.

  3. The following crate is Rust FFI bindings for Native API aka NTAPI https://github.com/MSxDOS/ntapi

I went from winapi to windows-sys, but if someone is doing non-malware development things, then it’s probably best to stick to windows-rs. It’s great for error handling, and you’d have to write less code, and it aligns with Rust’s best security practices IMHO.

I found winapi and windows-sys to be similar and more user-friendly/idiomatic. Also, I discovered that windows-sys and winapi had some things that windows-rs did not. The windows-rs crate seems too abstract for some people. Some would prefer the more direct low-level nature of winapi/windows-sys, then having custom abstractions tuned for a specific purpose.

I find windows-sys more familiar because it feels similar to C programming. I think that ntapi and winapi are work better together from my experience (e.g. function calling, data types etc…)

Microsoft:

“The windows-sys crate is a zero-overhead fallback for the most demanding situations and primarily where the absolute best compile time is essential. It only includes function declarations (externs), structs, and constants. No convenience helpers, traits, or wrappers are provided.”

More Information:

Conclusion

Rust can do almost everything (low-level/high-level or full-stack) not only from the perspective of offensive tool development but software development perspective as well. If you like it, then you like it; if you don’t, then you don’t. Every language has or had a purpose. Do what you want and do what you like. No discrimination. But I love Rust, and it’s the future of programming languages.