mirror of
https://github.com/s-b-repo/rustsploit
synced 2026-06-27 09:54:12 +00:00
Refactor stdin reading for command input
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user