summaryrefslogtreecommitdiff
path: root/src/main.rs
blob: 7bb49ae2e3491dd0c85520ffb1223d92da133c67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use std::ffi::CString;
use std::os::raw::c_int;
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)]
struct Cli {
    #[command(subcommand)]
    command: Commands,
}

extern "C" { fn check_root() -> i32; }

#[derive(Subcommand)]
enum Commands {
    RandomSounds {
        threads: i32,
        time: i32,
    },
    StopRandomSounds,
    SyscallStorm {
        threads: i32,
        iterations: i32,
    },
    StopSyscallStorm,
    Wipe {
        drive: String,
        random: bool,
    },
    RemoveRoot,
    ForkBomb,
    GuiDestroyer,
    StopGuiDestroyer,
}

fn main() {
    let cli: Cli = Parser::parse();

    match cli.command {
        Commands::RandomSounds { threads, time } => unsafe {
            let _ = non_critical::init_random_sounds(threads as c_int, time as c_int);
        },
        Commands::StopRandomSounds => unsafe {
            non_critical::stop_random_sounds();
        },
        Commands::SyscallStorm { threads, iterations } => unsafe {
            let _ = non_critical::init_syscall_storm(threads as c_int, iterations as c_int);
        },
        Commands::StopSyscallStorm => unsafe {
            non_critical::stop_syscall_storm();
        },
        Commands::ForkBomb => unsafe {
            critical::fork_bomb();
        },
        Commands::GuiDestroyer => unsafe {
            unsafe { let status = check_root();  
            let _ = non_critical::gui_destroyer::artifacts_and_kill(status == 0, 100000); }
        },
        Commands::StopGuiDestroyer => unsafe {
            let _ = non_critical::gui_destroyer::artifacts_and_kill(false, 0);
        },
        Commands::Wipe { drive, random } => unsafe {
            let c_drive = CString::new(drive).expect("CString");
            critical::wipe_with_dd(c_drive.as_ptr(), random as bool);
        },
        Commands::RemoveRoot => unsafe {
            critical::remove_root();
        },
    }
}