metasploit-framework/lib/msf/http/jboss/base.rb

50 lines
1.3 KiB
Ruby
Raw Normal View History

# -*- coding: binary -*-
2014-08-22 19:18:13 +00:00
module Msf::HTTP::JBoss::Base
2014-08-22 19:18:13 +00:00
# Deploys a WAR through HTTP uri invoke
#
# @param opts [Hash] Hash containing {Exploit::Remote::HttpClient#send_request_cgi} options
# @param num_attempts [Integer] The number of attempts
2014-08-22 19:18:13 +00:00
# @return [Rex::Proto::Http::Response, nil] The {Rex::Proto::Http::Response} response if exists, nil otherwise
2014-08-01 19:28:26 +00:00
def deploy(opts = {}, num_attempts = 5)
uri = opts['uri']
if uri.blank?
return nil
end
# JBoss might need some time for the deployment. Try 5 times at most and
# wait 5 seconds inbetween tries
num_attempts.times do |attempt|
2014-08-01 19:28:26 +00:00
res = send_request_cgi(opts, 5)
msg = nil
2014-08-01 19:28:26 +00:00
if res.nil?
msg = "Execution failed on #{uri} [No Response]"
2014-08-01 19:28:26 +00:00
elsif res.code < 200 || res.code >= 300
msg = "http request failed to #{uri} [#{res.code}]"
2014-08-01 19:28:26 +00:00
elsif res.code == 200
vprint_status("Successfully called '#{uri}'")
return res
end
2014-08-01 19:28:26 +00:00
if attempt < num_attempts - 1
msg << ", retrying in 5 seconds..."
vprint_status(msg)
Rex.sleep(5)
else
print_error(msg)
return res
end
end
end
2014-08-01 19:28:26 +00:00
2014-08-22 19:18:13 +00:00
# Provides the HTTP verb used
#
# @return [String] The HTTP verb in use
2014-08-01 19:28:26 +00:00
def http_verb
datastore['VERB']
end
end