the server will now save the password that is provided or generated for
it to the systems keyring, and attempt to load it at run time. I also added the beginnings for ingesting shodan results for hosts into the tool. The attack client can now save servers, load them from the folder, and save/load the passwords to/from the system keyring.
This commit is contained in:
1 parent
96672190c4
commit
911189c095
7 files changed
+1204
-403
No files matched your search
+30
-1
@@ -1,3 +1,4 @@
|
||||
use keyring::Entry;
|
||||
use rcgen::generate_simple_self_signed;
|
||||
use std::error::Error;
|
||||
use std::fs;
|
||||
@@ -53,7 +54,7 @@ pub struct Server {
|
||||
}
|
||||
|
||||
pub async fn start_server(server: Arc<Mutex<Server>>) -> Result<(), Box<dyn Error>> {
|
||||
let lock = server.lock().unwrap();
|
||||
let mut lock = server.lock().unwrap();
|
||||
let mut name_path = lock.certificate_path.clone();
|
||||
name_path.pop();
|
||||
name_path.push("names.txt");
|
||||
@@ -90,6 +91,34 @@ pub async fn start_server(server: Arc<Mutex<Server>>) -> Result<(), Box<dyn Erro
|
||||
let cert = generate_simple_self_signed(current_config_names)?;
|
||||
write(&lock.certificate_path, cert.cert.pem())?;
|
||||
write(&lock.key_path, cert.signing_key.serialize_pem())?;
|
||||
println!("attempting to load saved password...");
|
||||
if let Ok(entry) = Entry::new("tetanus-server", &lock.address) {
|
||||
if let Ok(password) = entry.get_password() {
|
||||
lock.password = password;
|
||||
println!("password loaded from keyring!");
|
||||
} else {
|
||||
println!("error getting password, using randomly generated one.");
|
||||
if let Err(e) = entry.set_password(&lock.password) {
|
||||
println!("error saving generated password! {e}");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
println!("error creating entry, using randomly generated password.");
|
||||
}
|
||||
}
|
||||
println!("attempting to load saved password...");
|
||||
if let Ok(entry) = Entry::new("tetanus-server", &lock.address) {
|
||||
if let Ok(password) = entry.get_password() {
|
||||
lock.password = password;
|
||||
println!("password loaded from keyring!");
|
||||
} else {
|
||||
println!("error getting password, using randomly generated one.");
|
||||
if let Err(e) = entry.set_password(&lock.password) {
|
||||
println!("error saving generated password! {e}");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
println!("error creating entry, using randomly generated password.");
|
||||
}
|
||||
let certs = load_certs(&lock.certificate_path)?;
|
||||
let key = load_key(&lock.key_path)?;
|
||||
|
||||
Reference in new issue
Block a user