Added /shells route (wip)
This commit is contained in:
parent
4c4b3bc202
commit
8dc4b91ba2
@ -0,0 +1,29 @@
|
|||||||
|
use std::net::SocketAddr;
|
||||||
|
use axum::{
|
||||||
|
body::Body,
|
||||||
|
http::{Request, StatusCode},
|
||||||
|
response::IntoResponse
|
||||||
|
};
|
||||||
|
|
||||||
|
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 {
|
||||||
|
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("bash") {
|
||||||
|
Some(res) => (StatusCode::OK, replace_shell_params(&res, ip, &conf.shell_port)),
|
||||||
|
None => (StatusCode::NOT_FOUND, "Invalid shell name.".to_string()),
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user