added client type reporting and detection for the servers and clients to
handle different client types differently in the future.
This commit is contained in:
+15
-3
@@ -237,10 +237,10 @@ impl AppState {
|
|||||||
self.help
|
self.help
|
||||||
.push("test_server\ntest the server connection\n".to_string());
|
.push("test_server\ntest the server connection\n".to_string());
|
||||||
self.help.push(
|
self.help.push(
|
||||||
"add_scope\nadd a host, cidr range, or ip address to the current project's scope"
|
"add_scope\nadd a host, cidr range, or ip address to the current project's scope\n"
|
||||||
.to_string(),
|
.to_string(),
|
||||||
);
|
);
|
||||||
self.help.push("parse_scope\nparse the projects general.md notes file for the scope copied from the workbook".to_string());
|
self.help.push("parse_scope\nparse the projects general.md notes file for the scope copied from the workbook\n".to_string());
|
||||||
self.help.push("exit\nquit the tool\n".to_string());
|
self.help.push("exit\nquit the tool\n".to_string());
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -394,6 +394,18 @@ impl AppState {
|
|||||||
let _ = self.main_tx.send(ToolMessage::Output((rid, line)));
|
let _ = self.main_tx.send(ToolMessage::Output((rid, line)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"rebuild_distro_box" | "rdb" => {
|
||||||
|
if let Some(db) = self.projects[self.selected_project].db.clone() {
|
||||||
|
if db.created {
|
||||||
|
let _ = self.main_tx.send(ToolMessage::DestroyDB(db.clone()));
|
||||||
|
}
|
||||||
|
let _ = self.main_tx.send(ToolMessage::RebuildDB);
|
||||||
|
let _ = self.main_tx.send(ToolMessage::Output((
|
||||||
|
rid,
|
||||||
|
"[success] Distorbox made!".to_string(),
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
||||||
"promote_project" | "pp" => {
|
"promote_project" | "pp" => {
|
||||||
self.main_tx.send(ToolMessage::Output((
|
self.main_tx.send(ToolMessage::Output((
|
||||||
rid,
|
rid,
|
||||||
@@ -1230,7 +1242,7 @@ impl Server {
|
|||||||
self.cert_text = cert;
|
self.cert_text = cert;
|
||||||
}
|
}
|
||||||
let mut stream = self.tls_connect()?;
|
let mut stream = self.tls_connect()?;
|
||||||
stream.write("HELLO".as_bytes())?;
|
stream.write("HELLO|attack".as_bytes())?;
|
||||||
let mut buf = [0; 8192];
|
let mut buf = [0; 8192];
|
||||||
let bytes_read = stream.read(&mut buf)?;
|
let bytes_read = stream.read(&mut buf)?;
|
||||||
let response = String::from_utf8_lossy(&buf[..bytes_read]);
|
let response = String::from_utf8_lossy(&buf[..bytes_read]);
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ pub struct Client {
|
|||||||
last_check: Instant,
|
last_check: Instant,
|
||||||
remove: bool,
|
remove: bool,
|
||||||
name: String,
|
name: String,
|
||||||
|
victim: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Server {
|
pub struct Server {
|
||||||
@@ -184,6 +185,12 @@ where
|
|||||||
}
|
}
|
||||||
let msg = String::from_utf8_lossy(&buf[..n]);
|
let msg = String::from_utf8_lossy(&buf[..n]);
|
||||||
if msg.contains("HELLO") {
|
if msg.contains("HELLO") {
|
||||||
|
let mut victim = false;
|
||||||
|
if let Some((_, ctype)) = msg.split_once("|") {
|
||||||
|
if ctype.contains("victim") {
|
||||||
|
victim = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
let mut connected = false;
|
let mut connected = false;
|
||||||
let mut id = 0;
|
let mut id = 0;
|
||||||
if let Ok(mut lock) = server.lock() {
|
if let Ok(mut lock) = server.lock() {
|
||||||
@@ -200,6 +207,7 @@ where
|
|||||||
last_check: Instant::now(),
|
last_check: Instant::now(),
|
||||||
remove: false,
|
remove: false,
|
||||||
name: String::new(),
|
name: String::new(),
|
||||||
|
victim,
|
||||||
};
|
};
|
||||||
connected = true;
|
connected = true;
|
||||||
id = new_client.id.clone();
|
id = new_client.id.clone();
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ pub struct Server {
|
|||||||
impl Server {
|
impl Server {
|
||||||
pub fn connect(&mut self) -> Result<usize, Box<dyn Error>> {
|
pub fn connect(&mut self) -> Result<usize, Box<dyn Error>> {
|
||||||
let mut stream = self.tls_connect()?;
|
let mut stream = self.tls_connect()?;
|
||||||
stream.write("HELLO".as_bytes())?;
|
stream.write("HELLO|victim".as_bytes())?;
|
||||||
let mut buf = [0; 8192];
|
let mut buf = [0; 8192];
|
||||||
let bytes_read = stream.read(&mut buf)?;
|
let bytes_read = stream.read(&mut buf)?;
|
||||||
let response = String::from_utf8_lossy(&buf[..bytes_read]);
|
let response = String::from_utf8_lossy(&buf[..bytes_read]);
|
||||||
|
|||||||
Reference in New Issue
Block a user