Skip to content

Commit 23f06f2

Browse files
committed
Put support check before command generation, too
1 parent 3717595 commit 23f06f2

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

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

85+
8586
def generate(opts = {})
8687
opts[:arch] ||= module_info['AdaptedArch']
8788
opts[:code] = super
8889
@srvexe = generate_payload_exe(opts)
8990
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')
93+
end
9094
@pipe_cmd = generate_fetch_commands
9195
vprint_status("Command served: #{@pipe_cmd}")
9296
cmd = generate_pipe_command
@@ -99,19 +103,22 @@ def generate(opts = {})
99103

100104
def generate_pipe_command
101105
# TODO: Make a check method that determines if we support a platform/server/command combination
102-
#
103-
@pipe_uri = srvuri + 'p'
106+
if srvuri.length < 3
107+
@pipe_uri = srvuri + 'p'
108+
else
109+
@pipe_uri = srvuri[...3]
110+
end
111+
104112
case datastore['FETCH_COMMAND'].upcase
105113
when 'WGET'
106114
return _generate_wget_pipe
107115
when 'CURL'
108116
return _generate_curl_pipe
109117
else
110-
fail_with(Msf::Module::Failure::BadConfig, 'Unsupported Binary Selected')
118+
fail_with(Msf::Module::Failure::BadConfig, 'Unsupported Binary Selected for FETCH_PIPE option')
111119
end
112120
end
113121

114-
115122
def generate_fetch_commands
116123
# TODO: Make a check method that determines if we support a platform/server/command combination
117124
#

0 commit comments

Comments
 (0)