2014-07-17 22:56:32 +00:00
|
|
|
# -*- coding: binary -*-
|
2014-07-18 09:51:46 +00:00
|
|
|
module Msf::HTTP::JBoss::Base
|
2014-08-18 16:19:37 +00:00
|
|
|
# Call the specified uri to deploy the payload / stager
|
|
|
|
# @param opts [Hash] Hash of configuration options.
|
|
|
|
# @param num_attempts [Integer] The number of attempts
|
|
|
|
# @return [ClientRequest] or nil
|
2014-08-01 19:28:26 +00:00
|
|
|
def deploy(opts = {}, num_attempts = 5)
|
|
|
|
uri = opts['uri']
|
|
|
|
|
|
|
|
if uri.blank?
|
|
|
|
return nil
|
|
|
|
end
|
2014-07-17 22:56:32 +00:00
|
|
|
|
|
|
|
# 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)
|
2014-07-17 22:56:32 +00:00
|
|
|
msg = nil
|
2014-08-01 19:28:26 +00:00
|
|
|
if res.nil?
|
2014-07-17 22:56:32 +00:00
|
|
|
msg = "Execution failed on #{uri} [No Response]"
|
2014-08-01 19:28:26 +00:00
|
|
|
elsif res.code < 200 || res.code >= 300
|
2014-07-17 22:56:32 +00:00
|
|
|
msg = "http request failed to #{uri} [#{res.code}]"
|
2014-08-01 19:28:26 +00:00
|
|
|
elsif res.code == 200
|
2014-07-22 21:08:42 +00:00
|
|
|
vprint_status("Successfully called '#{uri}'")
|
2014-07-17 22:56:32 +00:00
|
|
|
return res
|
|
|
|
end
|
|
|
|
|
2014-08-01 19:28:26 +00:00
|
|
|
if attempt < num_attempts - 1
|
2014-07-17 22:56:32 +00:00
|
|
|
msg << ", retrying in 5 seconds..."
|
2014-07-22 21:08:42 +00:00
|
|
|
vprint_status(msg)
|
2014-07-24 20:58:58 +00:00
|
|
|
Rex.sleep(5)
|
2014-07-17 22:56:32 +00:00
|
|
|
else
|
|
|
|
print_error(msg)
|
|
|
|
return res
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-08-01 19:28:26 +00:00
|
|
|
|
|
|
|
def http_verb
|
|
|
|
datastore['VERB']
|
|
|
|
end
|
|
|
|
|
2014-07-17 22:56:32 +00:00
|
|
|
end
|