Skip to content

Commit 244d9ba

Browse files
committed
Add max timeout
1 parent 9116460 commit 244d9ba

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

lib/msf/core/exploit/remote/browser_exploit_server.rb

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,6 @@ def get_detection_html(user_agent)
388388
<%= js_misc_addons_detect %>
389389
<%= js_ie_addons_detect if os.match(OperatingSystems::Match::WINDOWS) and client == HttpClients::IE %>
390390
391-
var flash_version = "";
392-
var do_flash_loop = true;
393-
394391
function objToQuery(obj) {
395392
var q = [];
396393
for (var key in obj) {
@@ -410,11 +407,19 @@ def get_detection_html(user_agent)
410407
});
411408
}
412409
410+
var flashVersion = "";
411+
var doFlashLoop = true;
412+
var maxTimeout = null;
413+
413414
function setFlashVersion(ver) {
414415
console.log('called! :) ' + ver)
415-
flash_version = ver
416-
do_flash_loop = false
417-
console.log('flash version after set_version: ' + flash_version)
416+
flashVersion = ver
417+
doFlashLoop = false
418+
if (maxTimeout != null) {
419+
clearTimeout(maxTimeout);
420+
maxTimeout = null
421+
}
422+
console.log('flash version after set_version: ' + flashVersion)
418423
return;
419424
}
420425
@@ -483,23 +488,25 @@ def get_detection_html(user_agent)
483488
<% end %>
484489
485490
if (d["flash"] != null && (d["flash"].match(/[\\d]+.[\\d]+.[\\d]+.[\\d]+/)) == null) {
486-
alert('flash detection!')
487-
// Load SWF for accurate Flash detection
488-
// This SWF needs to send the Flash version info as a POST request to BES sort of like this:
491+
alert('flash detection!');
489492
var flashObject = createFlashObject('<%=get_resource.chomp("/")%>/<%=@flash_swf%>', {width: 1, height: 1}, {allowScriptAccess: 'always', Play: 'True'});
490493
494+
// After 5s stop waiting and use the version retrieved with JS
495+
maxTimeout = setTimeout(function(){ doFlashLoop = false }, 5000);
496+
497+
// Check every 100 ms
491498
(function loop(){
492-
console.log('loop: ' + flash_version)
499+
console.log('loop: ' + flashVersion)
493500
setTimeout(function(){
494-
if (do_flash_loop) {
501+
if (doFlashLoop) {
495502
loop()
496503
}
497-
console.log('finally: ' + flash_version)
498-
if (!isEmpty(flash_version)) {
499-
d["flash"] = flash_version
504+
console.log('finally: ' + flashVersion)
505+
if (!isEmpty(flashVersion)) {
506+
d["flash"] = flashVersion
500507
}
501508
sendInfo(d)
502-
}, 1000);
509+
}, 100);
503510
})();
504511
505512
document.body.appendChild(flashObject)
@@ -573,7 +580,7 @@ def on_request_uri(cli, request)
573580
vprint_status("Sending SWF used for Flash detection")
574581
swf = load_swf_detection
575582
send_response(cli, swf, {'Content-Type'=>'application/x-shockwave-flash', 'Cache-Control' => 'no-cache, no-store', 'Pragma' => 'no-cache'})
576-
583+
577584
when /#{@info_receiver_page}/
578585
#
579586
# The detection code will hit this if Javascript is enabled

0 commit comments

Comments
 (0)