|
11 | 11 | #
|
12 | 12 | # The BrowserExploitServer mixin provides methods to do common tasks seen in modern browser
|
13 | 13 | # 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 |
14 | 17 | #
|
15 | 18 | ###
|
16 | 19 |
|
@@ -87,10 +90,20 @@ def initialize(info={})
|
87 | 90 |
|
88 | 91 | register_advanced_options([
|
89 | 92 | 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)"]) |
91 | 95 | ], Exploit::Remote::BrowserExploitServer)
|
92 | 96 | end
|
93 | 97 |
|
| 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 | + |
94 | 107 | #
|
95 | 108 | # Allows a block of code to access BES resources in a thread-safe fashion
|
96 | 109 | #
|
@@ -578,5 +591,19 @@ def js_vuln_test
|
578 | 591 | end
|
579 | 592 | end
|
580 | 593 |
|
| 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 | + |
581 | 608 | end
|
582 | 609 | end
|
0 commit comments