2014-07-17 22:56:32 +00:00
|
|
|
# -*- coding: binary -*-
|
2014-08-22 19:18:13 +00:00
|
|
|
|
2014-07-18 09:51:46 +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
|
2014-08-18 16:19:37 +00:00
|
|
|
# @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
|
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
|
2014-07-22 21:08:42 +00:00
|
|
|
vprint_status("Successfully called '#{uri}'")
|
2014-07-17 22:56:32 +00:00
|
|
|
return res
|
2014-08-22 20:11:27 +00:00
|
|
|
else
|
|
|
|
msg = "http request failed to #{uri} [#{res.code}]"
|
2014-07-17 22:56:32 +00:00
|
|
|
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
|
|
|
|
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
|
|
|
|
|
2014-07-17 22:56:32 +00:00
|
|
|
end
|