added code to generate victim binaries, implemented client -> server
authentication and fixed a bug in the ui where not all output would be displayed.
This commit is contained in:
+45
@@ -1,6 +1,9 @@
|
||||
use clap::Parser;
|
||||
use rand::RngExt;
|
||||
use rand::distr::Alphanumeric;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::{env, path::PathBuf, process::exit};
|
||||
use sysinfo::*;
|
||||
use tetanus::funcs::*;
|
||||
use tetanus::server::start_server;
|
||||
use tetanus::{AppState, server};
|
||||
@@ -46,6 +49,20 @@ struct Args {
|
||||
help = "Custom Config file. Give the path to a config file to use."
|
||||
)]
|
||||
config: Option<PathBuf>,
|
||||
|
||||
#[arg(
|
||||
short = 'P',
|
||||
long,
|
||||
help = "the password for the server, in server mode it will set the password clients need to log in, in client mode it sets the password the client will use to login to the server. If blank it will generate a random password."
|
||||
)]
|
||||
password: Option<String>,
|
||||
|
||||
#[arg(
|
||||
short,
|
||||
long,
|
||||
help = "The name to set this instance, on servers it will name the server so clients know who it is, on clients it names the clinet for server communications. This defaults to the hostname of the machine, or if the hostname can't be determined it falls back to the username of who runs it."
|
||||
)]
|
||||
name: Option<String>,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
@@ -78,6 +95,22 @@ async fn main() {
|
||||
}
|
||||
let mut client_config_path = config_path.clone();
|
||||
client_config_path.push("client.conf");
|
||||
let mut name = String::new();
|
||||
let mut server_hostname = String::new();
|
||||
if let Some(aname) = args.name {
|
||||
name = aname;
|
||||
} else {
|
||||
if let Some(hostname) = System::host_name() {
|
||||
name = hostname.clone();
|
||||
server_hostname = hostname;
|
||||
} else {
|
||||
for (key, value) in env::vars() {
|
||||
if key == "USERNAME" || key == "USER" {
|
||||
name = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if args.client {
|
||||
if !client_config_path.exists() {
|
||||
eprintln!(
|
||||
@@ -92,6 +125,7 @@ async fn main() {
|
||||
eprintln!("error loading config!");
|
||||
exit(1);
|
||||
}
|
||||
appstate.name = name;
|
||||
appstate.initialize_modules();
|
||||
println!("entering tui...");
|
||||
let _res = run_tui(appstate, rx).unwrap();
|
||||
@@ -109,11 +143,22 @@ async fn main() {
|
||||
address = format!("{}:{}", ip.trim(), port.trim());
|
||||
}
|
||||
}
|
||||
let mut server_pass: String = rand::rng()
|
||||
.sample_iter(&Alphanumeric)
|
||||
.take(12)
|
||||
.map(char::from)
|
||||
.collect();
|
||||
if let Some(pass) = args.password {
|
||||
server_pass = pass;
|
||||
}
|
||||
let new_server = server::Server {
|
||||
address,
|
||||
clients: Vec::new(),
|
||||
certificate_path,
|
||||
key_path,
|
||||
password: server_pass,
|
||||
name,
|
||||
hostname: server_hostname,
|
||||
};
|
||||
let res = start_server(Arc::new(Mutex::new(new_server))).await;
|
||||
match res {
|
||||
|
||||
Reference in New Issue
Block a user