7 min read
|
Saved February 14, 2026
|
Copied!
Do you care about this?
This article outlines a method to create a Rust binary that behaves harmlessly under normal circumstances but runs a hidden program on a specific target host. It discusses the encryption of the hidden program and how to derive a decryption key from unique host data, ensuring the hidden code remains concealed. The approach is relevant for targeted malware and software licensing.
If you do, here's more
Creating a "Two-Face" Rust binary on Linux involves building an executable that typically runs harmless code but can execute a hidden program on a specific target machine. This technique can be useful for malware or software licensing protection. The key is to ensure that the binary doesn't reveal its true nature or the target's identity, which could lead to detection. A naive approach might simply check if itβs running on a target host and execute the appropriate program. However, this method leaves the hidden program exposed in memory and easily detectable through disassembly.
To improve security, the article suggests encrypting the hidden program and deriving the decryption key from unique host data. The steps include extracting identifying information from the target machine, generating a key using HKDF, and then decrypting the hidden program at runtime. If the decryption fails, the binary falls back to running the harmless code. This method prevents the hidden program from executing on unintended hosts, as the key derived from the target machine's details won't match on any other system.
Identifying suitable host data for key generation is critical. The data must be unique, stable over time, and difficult to guess. Options like user UID or WAN interface IPv6 have limitations, while hardware serial numbers and disk partition UUIDs offer better entropy and uniqueness. The final implementation involves using Rust to create a twoface crate that manages both the encryption of the hidden binary at build time and the decryption logic at runtime. The Rust library integrates all necessary logic, allowing developers to embed the hidden program securely and control the execution flow based on the environment.
Questions about this article
No questions yet.