Skip to content

Commit ec69c1e

Browse files
committed
fix: cmd plugin now uses --target/-T instead of --cmd-binary
1 parent e25d6e9 commit ec69c1e

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/plugins/cmd/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,20 @@ fn register() {
2020
#[derive(Clone)]
2121
pub(crate) struct Command {
2222
opts: options::Options,
23+
binary: String,
2324
}
2425

2526
impl Command {
2627
pub fn new() -> Self {
2728
Command {
2829
opts: options::Options::default(),
30+
binary: String::default(),
2931
}
3032
}
3133

3234
async fn run(&self, creds: &Credentials) -> Result<std::process::Output, Error> {
3335
let (target, port) = utils::parse_target(&creds.target, 0)?;
36+
3437
let args = shell_words::split(
3538
&self
3639
.opts
@@ -42,13 +45,13 @@ impl Command {
4245
)
4346
.unwrap();
4447

45-
log::debug!("{} {}", &self.opts.cmd_binary, args.join(" "));
48+
log::debug!("{} {}", &self.binary, args.join(" "));
4649

47-
let child = std::process::Command::new(&self.opts.cmd_binary)
50+
let child = std::process::Command::new(&self.binary)
4851
.args(&args)
4952
.stdin(Stdio::null())
50-
.stdout(Stdio::null())
51-
.stderr(Stdio::null())
53+
.stdout(Stdio::piped())
54+
.stderr(Stdio::piped())
5255
.spawn()
5356
.map_err(|e| e.to_string())?;
5457

@@ -63,12 +66,9 @@ impl Plugin for Command {
6366
}
6467

6568
fn setup(&mut self, opts: &Options) -> Result<(), Error> {
69+
self.binary = opts.target.clone().unwrap();
6670
self.opts = opts.cmd.clone();
67-
if self.opts.cmd_binary.is_empty() {
68-
Err("please provide --cmd-binary and optionally --cmd-args".to_owned())
69-
} else {
70-
Ok(())
71-
}
71+
Ok(())
7272
}
7373

7474
async fn attempt(&self, creds: &Credentials, timeout: Duration) -> Result<Option<Loot>, Error> {

src/plugins/cmd/options.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ use serde::{Deserialize, Serialize};
44
#[derive(Parser, Debug, Serialize, Deserialize, Clone, Default)]
55
#[group(skip)]
66
pub(crate) struct Options {
7-
#[clap(long, default_value = "")]
8-
/// Command binary path.
9-
pub cmd_binary: String,
10-
117
#[clap(long, default_value = "")]
128
/// Command arguments. {USERNAME}, {PASSWORD}, {TARGET} and {PORT} can be used as placeholders.
139
pub cmd_args: String,

0 commit comments

Comments
 (0)