Skip to content

Commit a2a522b

Browse files
committed
Land rapid7#6716, Add a rescue to catch method missing for stage_payload
2 parents 280aeb0 + 6523600 commit a2a522b

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

lib/msf/core/handler/reverse_http.rb

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -340,29 +340,34 @@ def on_request(cli, req, obj)
340340

341341
resp['Content-Type'] = 'application/octet-stream'
342342

343-
# generate the stage, but pass in the existing UUID and connection id so that
344-
# we don't get new ones generated.
345-
blob = obj.stage_payload(
346-
uuid: uuid,
347-
uri: conn_id,
348-
lhost: uri.host,
349-
lport: uri.port
350-
)
351-
352-
resp.body = encode_stage(blob)
353-
354-
# Short-circuit the payload's handle_connection processing for create_session
355-
create_session(cli, {
356-
:passive_dispatcher => obj.service,
357-
:conn_id => conn_id,
358-
:url => url,
359-
:expiration => datastore['SessionExpirationTimeout'].to_i,
360-
:comm_timeout => datastore['SessionCommunicationTimeout'].to_i,
361-
:retry_total => datastore['SessionRetryTotal'].to_i,
362-
:retry_wait => datastore['SessionRetryWait'].to_i,
363-
:ssl => ssl?,
364-
:payload_uuid => uuid
365-
})
343+
begin
344+
# generate the stage, but pass in the existing UUID and connection id so that
345+
# we don't get new ones generated.
346+
blob = obj.stage_payload(
347+
uuid: uuid,
348+
uri: conn_id,
349+
lhost: uri.host,
350+
lport: uri.port
351+
)
352+
353+
resp.body = encode_stage(blob)
354+
355+
# Short-circuit the payload's handle_connection processing for create_session
356+
create_session(cli, {
357+
:passive_dispatcher => obj.service,
358+
:conn_id => conn_id,
359+
:url => url,
360+
:expiration => datastore['SessionExpirationTimeout'].to_i,
361+
:comm_timeout => datastore['SessionCommunicationTimeout'].to_i,
362+
:retry_total => datastore['SessionRetryTotal'].to_i,
363+
:retry_wait => datastore['SessionRetryWait'].to_i,
364+
:ssl => ssl?,
365+
:payload_uuid => uuid
366+
})
367+
rescue NoMethodError
368+
print_error("Staging failed. This can occur when stageless listeners are used with staged payloads.")
369+
return
370+
end
366371

367372
when :connect
368373
print_status("Attaching orphaned/stageless session ...")

0 commit comments

Comments
 (0)