Skip to content

Commit cad929e

Browse files
committed
Merge pull request #33 from hmoore-r7/feature/bapv2-tweaks
A number of small fixes for BAPv2
2 parents 2276e35 + 100d3c8 commit cad929e

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

lib/msf/core/exploit/browser_autopwnv2.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,9 @@ def set_exploit_options(xploit)
140140
xploit.datastore['DisablePayloadHandler'] = true
141141
xploit.datastore['BrowserProfilePrefix'] = browser_profile_prefix
142142
xploit.datastore['URIPATH'] = "/#{assign_module_resource}"
143-
xploit.datastore['WORKSPACE'] = self.workspace
144143

145-
# TODO: Add BAPv2 tracking information (?) - HD
146-
# TODO: Change exploit output options? - HD
144+
# Register this module as a child and copy datastore options
145+
xploit.register_parent(self)
147146
end
148147

149148

@@ -152,12 +151,13 @@ def set_exploit_options(xploit)
152151
# @param resource [String] The resource to check.
153152
# @return [TrueClass] Resource is taken.
154153
# @return [FalseClass] Resource is not taken.
155-
# TODO: Prevent partial prefix match - HD
156154
def is_resource_taken?(resource)
157155
taken = false
158156

159157
bap_exploits.each do |m|
160-
return true if m.datastore['URIPATH'] == resource
158+
# Prevent partial matching of one resource within another
159+
return true if m.datastore['URIPATH'].index(resource)
160+
return true if resource.index(m.datastore['URIPATH'])
161161
end
162162

163163
taken
@@ -206,8 +206,10 @@ def sort_bap_exploits
206206
# @return [Hash] A hash with each module list sorted by disclosure date.
207207
def sort_date_in_group(bap_groups)
208208
bap_groups.each_pair do |ranking, module_list|
209-
# TODO: Handle wonky dates in local modules better - HD
210-
bap_groups[ranking] = module_list.sort_by {|m| Date.parse(m.disclosure_date.to_s)}.reverse
209+
bap_groups[ranking] = module_list.sort_by {|m|
210+
dstr = m.disclosure_date || "1970-01-01"
211+
Date.parse(dstr) rescue Date.parse("1970-01-01")
212+
}.reverse
211213
end
212214
end
213215

@@ -337,8 +339,9 @@ def start_payload_listeners
337339
# Configurable only by BAP
338340
multi_handler.datastore['ExitOnSession'] = false
339341
multi_handler.datastore['EXITFUNC'] = 'thread'
340-
multi_handler.datastore['WORKSPACE'] = self.workspace
341342

343+
# Register this module as a child and copy datastore options
344+
multi_handler.register_parent(self)
342345

343346
# Now we're ready to start the handler
344347
multi_handler.exploit_simple(

0 commit comments

Comments
 (0)