Skip to content

Commit 8ce1db5

Browse files
committed
Fix rapid7#4783, raise exception if the payload arch is incompatible
Fix rapid7#4783
1 parent 59c4136 commit 8ce1db5

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

lib/msf/core/exploit/remote/browser_exploit_server.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
module Msf
2121
module Exploit::Remote::BrowserExploitServer
2222

23+
class BESException < RuntimeError; end
24+
2325
include Msf::Exploit::Remote::HttpServer::HTML
2426
include Msf::Exploit::RopDb
2527
include Msf::Exploit::JSObfu
@@ -521,7 +523,13 @@ def on_request_uri(cli, request)
521523
try_set_target(profile)
522524
bad_reqs = get_bad_requirements(profile)
523525
if bad_reqs.empty?
524-
method(:on_request_exploit).call(cli, request, profile)
526+
begin
527+
method(:on_request_exploit).call(cli, request, profile)
528+
rescue BESException => e
529+
elog("BESException: #{e.message}\n#{e.backtrace * "\n"}")
530+
send_not_found(cli)
531+
print_error("BESException: #{e.message}")
532+
end
525533
else
526534
print_warning("Exploit requirement(s) not met: #{bad_reqs * ', '}. For more info: http://r-7.co/PVbcgx")
527535
if bad_reqs.include?(:vuln_test)
@@ -586,7 +594,15 @@ def get_payload(cli, browser_info)
586594
platform = platform.gsub(/^Mac OS X$/, 'OSX')
587595
platform = platform.gsub(/^Windows.*$/, 'Windows')
588596

589-
regenerate_payload(cli, platform, arch).encoded
597+
p = regenerate_payload(cli, platform, arch)
598+
599+
unless p.arch.include?(arch)
600+
err = "The payload arch (#{p.arch * ", "}) is incompatible with the #{arch} target. "
601+
err << "Please check your payload setting."
602+
raise BESException, err
603+
end
604+
605+
return p.encoded
590606
end
591607

592608
# @return [String] custom Javascript to check if a vulnerability is present

0 commit comments

Comments
 (0)