mirror of https://github.com/n1nj4sec/pupy.git
making shell_exec work on android
This commit is contained in:
parent
a485805447
commit
3c66543758
|
@ -10,11 +10,19 @@ 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('-s', '--shell', help="default to /bin/sh on linux or cmd.exe on windows")
|
||||
self.arg_parser.add_argument('argument')
|
||||
def run(self, args):
|
||||
res=""
|
||||
try:
|
||||
if self.client.is_android():
|
||||
if args.shell is None:
|
||||
args.shell="/system/bin/sh"
|
||||
if args.shell is None:
|
||||
res=self.client.conn.modules.subprocess.check_output(args.argument, stderr=subprocess.PIPE, stdin=subprocess.PIPE, shell=True, universal_newlines=True)
|
||||
else:
|
||||
command=[args.shell, '-c'] + args.argument.split()
|
||||
res=self.client.conn.modules.subprocess.check_output(command, stderr=subprocess.PIPE, stdin=subprocess.PIPE, universal_newlines=True)
|
||||
except Exception as e:
|
||||
if hasattr(e,'output') and e.output:
|
||||
res=e.output
|
||||
|
|
Loading…
Reference in New Issue