Skip to content

Commit 3b65f31

Browse files
author
lmercer
committed
post/multi/manage/sudo improved with the PASSWORD option
as described in Redmine Feature rapid7#7581
1 parent ad3ca3a commit 3b65f31

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

modules/post/multi/manage/sudo.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ def initialize(info={})
3030
versions from 2008 and later which support -A.
3131
},
3232
'License' => MSF_LICENSE,
33-
'Author' => [ 'todb <todb[at]metasploit.com>'],
33+
'Author' => [ 'todb <todb[at]metasploit.com>',
34+
'Ryan Baxendale <rbaxendale[at]gmail.com>' #added password option
35+
],
3436
'Platform' => [ 'linux','unix','osx','solaris','aix' ],
3537
'References' =>
3638
[
@@ -39,6 +41,11 @@ def initialize(info={})
3941
],
4042
'SessionTypes' => [ 'shell' ] # Need to test 'meterpreter'
4143
))
44+
45+
register_options(
46+
[
47+
OptString.new('PASSWORD', [false, 'The password to use when running sudo.'])
48+
], self.class)
4249
end
4350

4451
# Run Method for when run command is issued
@@ -57,7 +64,12 @@ def run
5764
end
5865

5966
def get_root
60-
password = session.exploit_datastore['PASSWORD']
67+
if datastore['PASSWORD']
68+
password = datastore['PASSWORD']
69+
else
70+
password = session.exploit_datastore['PASSWORD']
71+
end
72+
6173
if password.to_s.empty?
6274
print_status "No password available, trying a passwordless sudo."
6375
else

0 commit comments

Comments
 (0)