Skip to content

Commit 1e30cd5

Browse files
committed
Land rapid7#2740 - Real regex for MATCH and EXCLUDE
2 parents 9c59919 + cd66cca commit 1e30cd5

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

modules/auxiliary/server/browser_autopwn.rb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
##
55

66
# ideas:
7-
# - add a loading page option so the user can specify arbitrary html to
8-
# insert all of the evil js and iframes into
9-
# - caching is busted when different browsers come from the same IP
7+
# - add a loading page option so the user can specify arbitrary html to
8+
# insert all of the evil js and iframes into
9+
# - caching is busted when different browsers come from the same IP
1010

1111
require 'msf/core'
1212
require 'rex/exploitation/js/detect'
@@ -69,10 +69,10 @@ def initialize(info = {})
6969
register_advanced_options([
7070
OptString.new('AutoRunScript', [false, "A script to automatically on session creation.", '']),
7171
OptBool.new('AutoSystemInfo', [true, "Automatically capture system information on initialization.", true]),
72-
OptString.new('MATCH', [false,
72+
OptRegexp.new('MATCH', [false,
7373
'Only attempt to use exploits whose name matches this regex'
7474
]),
75-
OptString.new('EXCLUDE', [false,
75+
OptRegexp.new('EXCLUDE', [false,
7676
'Only attempt to use exploits whose name DOES NOT match this regex'
7777
]),
7878
OptBool.new('DEBUG', [false,
@@ -825,10 +825,12 @@ def build_script_response(cli, request)
825825
# Yields each module that exports autopwn_info, filtering on MATCH and EXCLUDE options
826826
#
827827
def each_autopwn_module(&block)
828-
m_regex = datastore["MATCH"] ? %r{#{datastore["MATCH"]}} : %r{}
829-
e_regex = datastore["EXCLUDE"] ? %r{#{datastore["EXCLUDE"]}} : %r{^$}
828+
m_regex = datastore["MATCH"]
829+
e_regex = datastore["EXCLUDE"]
830830
framework.exploits.each_module do |name, mod|
831-
if (mod.respond_to?("autopwn_opts") and name =~ m_regex and name !~ e_regex)
831+
if mod.respond_to?("autopwn_opts") and
832+
(m_regex.blank? or name =~ m_regex) and
833+
(e_regex.blank? or name !~ e_regex)
832834
yield name, mod
833835
end
834836
end

0 commit comments

Comments
 (0)