Skip to content

Commit

Permalink
misc: small fix or general refactoring i did not bother commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Jan 15, 2024
1 parent 7e816cc commit ef398e2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ fn setup() -> Result<Options, session::Error> {

// get new argv from recipe
let argv = recipe.to_argv(options.plugin.as_ref().unwrap_or(&"".to_string()))?;

log::debug!(" argv={:?}", &argv);

// repopulate the options from this argv
options.try_update_from(argv).map_err(|e| e.to_string())?;
}
Expand Down
9 changes: 3 additions & 6 deletions src/plugins/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use async_trait::async_trait;
use ctor::ctor;

use crate::session::{Error, Loot};
use crate::Options;
use crate::Plugin;
use crate::{utils, Options};

use crate::creds::Credentials;

Expand All @@ -30,16 +30,13 @@ impl Command {
}

async fn run(&self, creds: &Credentials) -> Result<std::process::Output, Error> {
let (target, port) = utils::parse_target(&creds.target, 0)?;

let args = shell_words::split(
&self
.opts
.cmd_args
.replace("{USERNAME}", &creds.username)
.replace("{PASSWORD}", &creds.password)
.replace("{TARGET}", &target)
.replace("{PORT}", &format!("{}", port)),
.replace("{TARGET}", &creds.target),
)
.unwrap();

Expand Down Expand Up @@ -81,7 +78,7 @@ impl Plugin for Command {
let stdout = String::from_utf8_lossy(&out.stdout);
let stderr = String::from_utf8_lossy(&out.stderr);
if !stderr.is_empty() {
log::error!("{}", stderr);
log::debug!("{}", stderr);
}

log::debug!("{}", &stdout);
Expand Down
4 changes: 3 additions & 1 deletion src/recipe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ impl Recipe {

for (arg_name, arg_value) in &self.args {
argv.push(format!("--{}", arg_name));
argv.push(self.parse_arg(arg_value, &mut ctx)?);
if arg_value != "null" {
argv.push(self.parse_arg(arg_value, &mut ctx)?);
}
}

// print context
Expand Down

0 comments on commit ef398e2

Please sign in to comment.