Skip to content

Commit

Permalink
fix: cmd plugin now uses --target/-T instead of --cmd-binary
Browse files Browse the repository at this point in the history
  • Loading branch information
evilsocket committed Dec 20, 2023
1 parent e25d6e9 commit ec69c1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/plugins/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,20 @@ fn register() {
#[derive(Clone)]
pub(crate) struct Command {
opts: options::Options,
binary: String,
}

impl Command {
pub fn new() -> Self {
Command {
opts: options::Options::default(),
binary: String::default(),
}
}

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
Expand All @@ -42,13 +45,13 @@ impl Command {
)
.unwrap();

log::debug!("{} {}", &self.opts.cmd_binary, args.join(" "));
log::debug!("{} {}", &self.binary, args.join(" "));

let child = std::process::Command::new(&self.opts.cmd_binary)
let child = std::process::Command::new(&self.binary)
.args(&args)
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
.map_err(|e| e.to_string())?;

Expand All @@ -63,12 +66,9 @@ impl Plugin for Command {
}

fn setup(&mut self, opts: &Options) -> Result<(), Error> {
self.binary = opts.target.clone().unwrap();
self.opts = opts.cmd.clone();
if self.opts.cmd_binary.is_empty() {
Err("please provide --cmd-binary and optionally --cmd-args".to_owned())
} else {
Ok(())
}
Ok(())
}

async fn attempt(&self, creds: &Credentials, timeout: Duration) -> Result<Option<Loot>, Error> {
Expand Down
4 changes: 0 additions & 4 deletions src/plugins/cmd/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ use serde::{Deserialize, Serialize};
#[derive(Parser, Debug, Serialize, Deserialize, Clone, Default)]
#[group(skip)]
pub(crate) struct Options {
#[clap(long, default_value = "")]
/// Command binary path.
pub cmd_binary: String,

#[clap(long, default_value = "")]
/// Command arguments. {USERNAME}, {PASSWORD}, {TARGET} and {PORT} can be used as placeholders.
pub cmd_args: String,
Expand Down

0 comments on commit ec69c1e

Please sign in to comment.