Removed unnecessary replace_shell_params function

This commit is contained in:
Random936 2024-12-22 18:52:37 -08:00
parent 8dc4b91ba2
commit a3b49ed7fc

View File

@ -1,4 +1,3 @@
use std::net::SocketAddr;
use axum::{ use axum::{
body::Body, body::Body,
http::{Request, StatusCode}, http::{Request, StatusCode},
@ -7,11 +6,6 @@ use axum::{
use crate::config; 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<Body>) -> impl IntoResponse { pub async fn shells_handler(req: Request<Body>) -> impl IntoResponse {
let conf = config::load_config(); let conf = config::load_config();
let Some(host) = req.headers() let Some(host) = req.headers()
@ -22,8 +16,11 @@ pub async fn shells_handler(req: Request<Body>) -> impl IntoResponse {
let ip = host.split(":").next().unwrap(); let ip = host.split(":").next().unwrap();
match conf.get_shell("bash") { 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()), None => (StatusCode::NOT_FOUND, "Invalid shell name.".to_string()),
} }
} }