Skip to content

Commit 66703bf

Browse files
committed
Allow custom 404 as an option for BrowserExploitServer
When something fails, the target is given a hardcoded 404 message generated by the framework. But the user (attacker) now can configure this. When the Custom404 option is set, the mixin will actually redirect (302) to that URL. There are several scenarios that can trigger a 404 by BES (custom or default): * When the browser doesn't allow javascript * When the browser directly visits the exploit URL, which is forbidden. If this actually happens, it probably means the attacker gave the wrong URL. * The attacker doesn't allow the browser auto-recovery to retry the URL. * If some browser requirements aren't met. * The browser attempts to go to access a resource not set up by the mixin.
1 parent 465b4a5 commit 66703bf

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#
1212
# The BrowserExploitServer mixin provides methods to do common tasks seen in modern browser
1313
# exploitation, and is designed to work against common setups such as on Windows, OSX, and Linux.
14+
# Wiki documentations about this mixin can be found here:
15+
# https://github.com/rapid7/metasploit-framework/wiki/How-to-write-a-browser-exploit-using-BrowserExploitServer
16+
# https://github.com/rapid7/metasploit-framework/wiki/Information-About-Unmet-Browser-Exploit-Requirements
1417
#
1518
###
1619

@@ -87,10 +90,20 @@ def initialize(info={})
8790

8891
register_advanced_options([
8992
OptString.new('CookieName', [false, "The name of the tracking cookie", DEFAULT_COOKIE_NAME]),
90-
OptString.new('CookieExpiration', [false, "Cookie expiration in years (blank=expire on exit)"])
93+
OptString.new('CookieExpiration', [false, "Cookie expiration in years (blank=expire on exit)"]),
94+
OptString.new('Custom404', [false, "An external custom 404 URL (Example: http://example.com/404.html)"])
9195
], Exploit::Remote::BrowserExploitServer)
9296
end
9397

98+
#
99+
# Returns the custom 404 URL set by the user
100+
#
101+
# @return [String]
102+
#
103+
def get_custom_404_url
104+
datastore['Custom404'].to_s
105+
end
106+
94107
#
95108
# Allows a block of code to access BES resources in a thread-safe fashion
96109
#
@@ -578,5 +591,19 @@ def js_vuln_test
578591
end
579592
end
580593

594+
private
595+
596+
#
597+
# Sends a 404 respons. If a custom 404 is configured, then it will redirect to that instead.
598+
#
599+
def send_not_found(cli)
600+
custom_404_url = get_custom_404_url
601+
if custom_404_url.blank?
602+
super(cli)
603+
else
604+
send_redirect(cli, custom_404_url)
605+
end
606+
end
607+
581608
end
582609
end

0 commit comments

Comments
 (0)