2014-07-17 22:56:32 +00:00
|
|
|
# -*- coding: binary -*-
|
2014-07-18 09:51:46 +00:00
|
|
|
module Msf::HTTP::JBoss::Base
|
2014-07-17 22:56:32 +00:00
|
|
|
def call_uri_mtimes(uri, num_attempts = 5, verb = nil, data = nil)
|
2014-07-22 21:08:42 +00:00
|
|
|
verb = datastore['VERB'] if verb.nil?
|
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|
|
|
|
|
|
|
|
|
if (verb == "POST")
|
|
|
|
res = send_request_cgi(
|
|
|
|
{
|
|
|
|
'uri' => uri,
|
|
|
|
'method' => verb,
|
|
|
|
'data' => data
|
|
|
|
}, 5)
|
|
|
|
else
|
|
|
|
|
|
|
|
uri += "?#{data}" unless data.nil?
|
|
|
|
res = send_request_cgi(
|
|
|
|
{
|
|
|
|
'uri' => uri,
|
|
|
|
'method' => verb
|
|
|
|
}, 30)
|
|
|
|
end
|
|
|
|
|
|
|
|
msg = nil
|
|
|
|
if (!res)
|
|
|
|
msg = "Execution failed on #{uri} [No Response]"
|
|
|
|
elsif (res.code < 200 or res.code >= 300)
|
|
|
|
msg = "http request failed to #{uri} [#{res.code}]"
|
|
|
|
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
|
|
|
|
|
|
|
|
if (attempt < num_attempts - 1)
|
|
|
|
msg << ", retrying in 5 seconds..."
|
2014-07-22 21:08:42 +00:00
|
|
|
vprint_status(msg)
|
2014-07-17 22:56:32 +00:00
|
|
|
select(nil, nil, nil, 5)
|
|
|
|
else
|
|
|
|
print_error(msg)
|
|
|
|
return res
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|