Rust Async RAT Framework
A recurring build pattern observed in modern Windows RAT/stealer families: native Rust compiled with the MSVC toolchain, using tokio for async I/O, tokio-tungstenite for WebSocket C2, serde_json for structured tasking, and BCrypt/CryptUnprotectData for config encryption. The builder emits a single PE32+ GUI executable with no packing, heavy IAT (300+ imports), and embedded AES-GCM config JSON toggling 50+ features.
Detection / Fingerprint
- Strings contain
.cargo\registry\src\index.crates.io-<hash>\tokio-1.x\src\...paths - Embedded
ServerMessageadjacently-tagged enum with 50–80 variants - Hardcoded WebSocket host/port, auth token, and E2E AES-GCM string (e.g.
dolphin-e2e-aes256gcm-v1) - Heavy Electron/browser injection JavaScript shipped as string literals inside the Rust binary
- Large
.rdatasection (>1 MB) containing serialized JSON field names and task enums - No UPX packing; entropy typically 6.0–7.0 in
.xdata/.rdataand ~8.0 in.datax
Reproduce on your own VMs
- Install Rust nightly +
cargoon Windows x64. - Add dependencies to
Cargo.toml:tokio = { version = "1.52", features = ["full"] }tokio-tungstenite = "0.21"serde = { version = "1.0", features = ["derive"] }serde_json = "1.0"windows = { version = "0.52", features = ["Win32_Security_Cryptography", ...] }
- Define a
ServerMessageenum with#[serde(tag = "type")]and ~10 representative variants. - Encrypt a JSON config blob via AES-GCM (key derived from a static passphrase) and embed with
include_bytes!. - At runtime decrypt via
BCryptOpenAlgorithmProvider→BCryptGenerateSymmetricKey→BCryptDecrypt. - Build with
cargo build --release --target x86_64-pc-windows-msvc. - Sign (optional) or strip; observe strings for
tokio-1.52.1paths andServerMessagevariant names.
Defensive Countermeasures
- YARA on
.cargo\registry\src\index.crates.iostring clusters + largeServerMessageenum. - Network: block hardcoded WebSocket SNI + monitor for
Upgrade: websocketheaders from non-browser signed binaries. - Endpoint:
CreateRemoteThread+SetWindowsHookExinto Electron processes from a non-canonicalNVIDIAorRuntimeBrokerimage.
Pages where observed
- dolphin — full deep-dive with 80+ task types, browser/wallet injection, polymorphic morph.