Identifier / Programs / Linux and Unix
rustc
The Rust compiler. Rust projects usually use cargo instead of invoking rustc directly. tldr-pages
GTFOBins file-write, inherit 3 documented commands
How rustc is abused
file-write
-oinherit
--explainEach abuse is GTFOBins's category and the options and words it uses; the full write-up is on GTFOBins's page for rustc.
3 documented commands
file-read unprivileged, with sudo
The compiler leaks some file lines in the compiler error.
rustc /path/to/input-fileIdentifyfile-write unprivileged, with sudo
The comment appears in the compiled program.
echo 'fn main() { println!("DATA"); }' >/path/to/temp-file
rustc /path/to/temp-file -o /path/to/output-fileIdentifyinherit unprivileged, with sudo
rustc --explain E0001IdentifyNone of the 3 commands the identifier reads trips a Sigma process-creation rule. These commands are, with GTFOBins’ notes, from GTFOBins, at commit acd524623f9c of 2026-05-27, under the GPL-3.0, with no warranty. Changed: Markdown is shown formatted. The source is in lolbas-gtfobins-commands.json.gz, and the full entry is on GTFOBins’s page for rustc. The identifier reads the line of each that runs rustc.
Everyday use
Compile a binary crate
rustc path/to/main.rsIdentifyCompile with optimizations (s means optimize for binary size; z is the same with even more optimizations)
rustc --codegen lto --codegen opt-level=0 path/to/main.rsIdentifyCompile with debugging information
rustc [-g|--codegen debuginfo=2] path/to/main.rsIdentifyNone of the 3 examples the identifier reads matches GTFOBins abuse or trips a Sigma process-creation rule.