Made shell dynamic for /shells route
This commit is contained in:
parent
a3b49ed7fc
commit
ceb1ab44d3
@ -1,12 +1,13 @@
|
|||||||
use axum::{
|
use axum::{
|
||||||
body::Body,
|
body::Body,
|
||||||
|
extract::Path,
|
||||||
http::{Request, StatusCode},
|
http::{Request, StatusCode},
|
||||||
response::IntoResponse
|
response::IntoResponse
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::config;
|
use crate::config;
|
||||||
|
|
||||||
pub async fn shells_handler(req: Request<Body>) -> impl IntoResponse {
|
pub async fn shells_handler(Path(shell): Path<String>, 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()
|
||||||
.get("host")
|
.get("host")
|
||||||
@ -15,7 +16,7 @@ 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(&shell) {
|
||||||
Some(res) => {
|
Some(res) => {
|
||||||
let cmd = res.replace("{LHOST}", ip)
|
let cmd = res.replace("{LHOST}", ip)
|
||||||
.replace("{LPORT}", &conf.shell_port.to_string());
|
.replace("{LPORT}", &conf.shell_port.to_string());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user