diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/critical/classic/mod.rs | 14 | ||||
| -rw-r--r-- | src/main.rs | 11 | ||||
| -rw-r--r-- | src/non_critical/_tools.c | 10 | ||||
| -rw-r--r-- | src/non_critical/gui_destroyer.rs | 21 | ||||
| -rw-r--r-- | src/non_critical/kern_panic/mod.rs | 11 | ||||
| -rw-r--r-- | src/non_critical/mod.rs | 6 |
6 files changed, 30 insertions, 43 deletions
diff --git a/src/critical/classic/mod.rs b/src/critical/classic/mod.rs deleted file mode 100644 index f72a5a0..0000000 --- a/src/critical/classic/mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -use std::os::raw::c_char; - -extern "C" { - pub fn random_data_linux(sym_drive: *const c_char, random: bool); - pub fn rm_root(); -} - -pub unsafe fn wipe_with_dd(sym_drive: *const c_char, random: bool) { - random_data_linux(sym_drive, random); -} - -pub unsafe fn remove_root() { - rm_root(); -} diff --git a/src/main.rs b/src/main.rs index f2aff63..5c695e9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,9 +6,6 @@ use clap::{Parser, Subcommand}; mod non_critical; mod critical; -#[path = "critical/classic/mod.rs"] -mod critical_classic; - #[derive(Parser)] #[command(name = "suicidekit")] #[command(about = "Toolkit: Critical and non-critical loads", long_about = None)] @@ -62,11 +59,11 @@ fn main() { Commands::ForkBomb => unsafe { critical::fork_bomb(); }, - Commands::GuiDestroyer => unsafe { - unsafe { let status = check_root(); - let _ = non_critical::gui_destroyer::artifacts_and_kill(status == 1, 100000); } + Commands::GuiDestroyer => { + let status = unsafe { check_root() }; + let _ = non_critical::gui_destroyer::artifacts_and_kill(status == 1, 100000); }, - Commands::StopGuiDestroyer => unsafe { + Commands::StopGuiDestroyer => { let _ = non_critical::gui_destroyer::artifacts_and_kill(false, 0); }, Commands::Wipe { drive, random } => unsafe { diff --git a/src/non_critical/_tools.c b/src/non_critical/_tools.c index 4b6159d..967c820 100644 --- a/src/non_critical/_tools.c +++ b/src/non_critical/_tools.c @@ -35,7 +35,15 @@ char* get_os_name() { if (end != NULL) { *end = '\0'; } - return name; + + // Allocate memory for the result and copy the string + char* result = malloc(strlen(name) + 1); + if (result != NULL) { + strcpy(result, name); + } + + fclose(file); + return result; } } diff --git a/src/non_critical/gui_destroyer.rs b/src/non_critical/gui_destroyer.rs index 126f0a6..97ac74e 100644 --- a/src/non_critical/gui_destroyer.rs +++ b/src/non_critical/gui_destroyer.rs @@ -1,15 +1,12 @@ -#![no_main] -#![feature(let_chains)] - use std::ffi::CStr; -use std::io::Write; -use std::ptr; -use std::fs::OpenOptions; -use std::os::unix::io::{AsRawFd, IntoRawFd}; +use std::io::Write; +use std::ptr; +use std::fs::OpenOptions; +use std::os::unix::io::IntoRawFd; use std::os::raw::c_char; use std::error::Error; -use rand::{Rng}; +use rand::Rng; use x11::xlib; use wayland_client::{Display, GlobalManager, Main}; @@ -34,10 +31,10 @@ pub fn artifacts_and_kill(root: bool, iterations: i32) -> Result<(), std::io::Er } let mut fb = std::fs::File::open("/dev/fb0").unwrap(); - let mut rng = rand::thread_rng(); - + let mut rng = rand::rng(); + for _ in 0..iterations { - let garbage: Vec<u8> = (0..1024).map(|_| rng.gen()).collect(); + let garbage: Vec<u8> = (0..1024).map(|_| rng.random()).collect(); let _ = fb.write(&garbage); } @@ -106,7 +103,7 @@ fn wayland_corrupt_buffer() -> Result<(), Box<dyn Error>> { .map_err(|_| "wl_shm not available")?; let tmp_path = std::env::temp_dir().join(format!("wl_broken_{}.tmp", std::process::id())); - let mut f = OpenOptions::new() + let f = OpenOptions::new() .read(true) .write(true) .create(true) diff --git a/src/non_critical/kern_panic/mod.rs b/src/non_critical/kern_panic/mod.rs index 4dccc34..d6accd9 100644 --- a/src/non_critical/kern_panic/mod.rs +++ b/src/non_critical/kern_panic/mod.rs @@ -13,22 +13,23 @@ pub unsafe fn sysrq_panic() { } pub fn kmod_panic() -> Result<(), String> { - let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap_or_else(|_| "target/debug".into())); + let out_dir = PathBuf::from(env::var("OUT_DIR") + .map_err(|_| "OUT_DIR environment variable not set".to_string())?); let ko_file = out_dir.join("linux_kmod.ko"); - + if !ko_file.exists() { return Err(format!("Kernel module not found at: {}", ko_file.display())); } - + let status = Command::new("insmod") .arg(&ko_file) .status() .map_err(|e| format!("Failed to execute insmod: {}", e))?; - + if !status.success() { return Err(format!("Failed to load kernel module: exit code {:?}", status.code())); } - + Ok(()) } diff --git a/src/non_critical/mod.rs b/src/non_critical/mod.rs index 884e0f0..a94ac68 100644 --- a/src/non_critical/mod.rs +++ b/src/non_critical/mod.rs @@ -4,16 +4,14 @@ pub mod kern_panic; use std::os::raw::{c_char, c_int}; extern "C" { - // Tools + // Tools pub fn check_root() -> c_int; - pub fn check_pid(pid: c_int) -> c_int; - pub fn get_os_name() -> *mut c_char; pub fn get_desktop_server() -> *mut c_char; // Random sounds pub fn init_random_sounds(threads: c_int, time: c_int) -> c_int; pub fn stop_random_sounds(); - + // Syscall storm pub fn init_syscall_storm(threads: c_int, iterations: c_int) -> c_int; pub fn stop_syscall_storm(); |
