Skip to content

Commit 8928c55

Browse files
committed
Fix Javascript code
1 parent 244d9ba commit 8928c55

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

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

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -408,18 +408,17 @@ def get_detection_html(user_agent)
408408
}
409409
410410
var flashVersion = "";
411-
var doFlashLoop = true;
411+
var doInterval = true;
412412
var maxTimeout = null;
413+
var intervalTimeout = null;
413414
414415
function setFlashVersion(ver) {
415-
console.log('called! :) ' + ver)
416416
flashVersion = ver
417-
doFlashLoop = false
418417
if (maxTimeout != null) {
419418
clearTimeout(maxTimeout);
420419
maxTimeout = null
421420
}
422-
console.log('flash version after set_version: ' + flashVersion)
421+
doInterval = false
423422
return;
424423
}
425424
@@ -446,8 +445,6 @@ def get_detection_html(user_agent)
446445
div.innerHTML = html;
447446
obj = div.firstChild;
448447
div.removeChild(obj);
449-
console.log(obj)
450-
alert('check obj')
451448
return obj;
452449
}
453450
@@ -488,26 +485,30 @@ def get_detection_html(user_agent)
488485
<% end %>
489486
490487
if (d["flash"] != null && (d["flash"].match(/[\\d]+.[\\d]+.[\\d]+.[\\d]+/)) == null) {
491-
alert('flash detection!');
492488
var flashObject = createFlashObject('<%=get_resource.chomp("/")%>/<%=@flash_swf%>', {width: 1, height: 1}, {allowScriptAccess: 'always', Play: 'True'});
493489
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
498-
(function loop(){
499-
console.log('loop: ' + flashVersion)
500-
setTimeout(function(){
501-
if (doFlashLoop) {
502-
loop()
503-
}
504-
console.log('finally: ' + flashVersion)
490+
// After 5s stop waiting and use the version retrieved with JS if there isn't anything
491+
maxTimeout = setTimeout(function() {
492+
if (intervalTimeout != null) {
493+
doInterval = false
494+
clearInterval(intervalTimeout)
495+
}
496+
if (!isEmpty(flashVersion)) {
497+
d["flash"] = flashVersion
498+
}
499+
sendInfo(d);
500+
}, 5000);
501+
502+
// Check if there is a new flash version every 100ms
503+
intervalTimeout = setInterval(function() {
504+
if (!doInterval) {
505+
clearInterval(intervalTimeout);
505506
if (!isEmpty(flashVersion)) {
506507
d["flash"] = flashVersion
507508
}
508-
sendInfo(d)
509-
}, 100);
510-
})();
509+
sendInfo(d);
510+
}
511+
}, 100);
511512
512513
document.body.appendChild(flashObject)
513514
} else {

0 commit comments

Comments
 (0)