diff --git a/src/shells.rs b/src/shells.rs index acb6018..7f6443b 100644 --- a/src/shells.rs +++ b/src/shells.rs @@ -1,4 +1,3 @@ -use std::net::SocketAddr; use axum::{ body::Body, http::{Request, StatusCode}, @@ -7,11 +6,6 @@ use axum::{ use crate::config; -fn replace_shell_params(cmd: &str, lhost: &str, lport: &u16) -> String { - cmd.replace("{LHOST}", lhost) - .replace("{LPORT}", &lport.to_string()) -} - pub async fn shells_handler(req: Request) -> impl IntoResponse { let conf = config::load_config(); let Some(host) = req.headers() @@ -22,8 +16,11 @@ pub async fn shells_handler(req: Request) -> impl IntoResponse { let ip = host.split(":").next().unwrap(); match conf.get_shell("bash") { - Some(res) => (StatusCode::OK, replace_shell_params(&res, ip, &conf.shell_port)), + Some(res) => { + let cmd = res.replace("{LHOST}", ip) + .replace("{LPORT}", &conf.shell_port.to_string()); + (StatusCode::OK, cmd) + }, None => (StatusCode::NOT_FOUND, "Invalid shell name.".to_string()), } - }