@@ -90,8 +90,7 @@ def initialize(info={})
90
90
@info_receiver_page = rand_text_alpha ( 5 )
91
91
@exploit_receiver_page = rand_text_alpha ( 6 )
92
92
@noscript_receiver_page = rand_text_alpha ( 7 )
93
- @flash_receiver_page = rand_text_alpha ( 8 )
94
- @flash_swf = rand_text_alpha ( 9 )
93
+ @flash_swf = "#{ rand_text_alpha ( 9 ) } .swf"
95
94
96
95
register_options (
97
96
[
@@ -333,11 +332,6 @@ def process_browser_info(source, cli, request)
333
332
334
333
# Gathering target info from the detection stage
335
334
case source
336
- when :flash
337
- # Flash version detection
338
- parsed_body = CGI ::parse ( Rex ::Text . decode_base64 ( request . body ) || '' )
339
- version_info = 'FLASH VERSION HERE'
340
- update_profile ( target_info , :flash , version_info )
341
335
when :script
342
336
# Gathers target data from a POST request
343
337
parsed_body = CGI ::parse ( Rex ::Text . decode_base64 ( request . body ) || '' )
@@ -394,6 +388,9 @@ def get_detection_html(user_agent)
394
388
<%= js_misc_addons_detect %>
395
389
<%= js_ie_addons_detect if os.match(OperatingSystems::Match::WINDOWS) and client == HttpClients::IE %>
396
390
391
+ var flash_version = "";
392
+ var do_flash_loop = true;
393
+
397
394
function objToQuery(obj) {
398
395
var q = [];
399
396
for (var key in obj) {
@@ -402,6 +399,52 @@ def get_detection_html(user_agent)
402
399
return Base64.encode(q.join('&'));
403
400
}
404
401
402
+ function isEmpty(str) {
403
+ return (!str \| \| 0 === str.length);
404
+ }
405
+
406
+ function sendInfo(info) {
407
+ var query = objToQuery(info);
408
+ postInfo("<%=get_resource.chomp("/")%>/<%=@info_receiver_page%>/", query, function(){
409
+ window.location="<%= get_module_resource %>";
410
+ });
411
+ }
412
+
413
+ function setFlashVersion(ver) {
414
+ console.log('called! :) ' + ver)
415
+ flash_version = ver
416
+ do_flash_loop = false
417
+ console.log('flash version after set_version: ' + flash_version)
418
+ return;
419
+ }
420
+
421
+ function createFlashObject(src, attributes, parameters) {
422
+ var i, html, div, obj, attr = attributes \| \| {}, param = parameters \| \| {};
423
+ attr.type = 'application/x-shockwave-flash';
424
+ if (window.ActiveXObject) {
425
+ attr.classid = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
426
+ param.movie = src;
427
+ } else {
428
+ attr.data = src;
429
+ }
430
+
431
+ html = '<object';
432
+ for (i in attr) {
433
+ html += ' ' + i + '="' + attr[i] + '"';
434
+ }
435
+ html += '>';
436
+ for (i in param) {
437
+ html += '<param name="' + i + '" value="' + param[i] + '" />';
438
+ }
439
+ html += '</object>';
440
+ div = document.createElement('div');
441
+ div.innerHTML = html;
442
+ obj = div.firstChild;
443
+ div.removeChild(obj);
444
+ console.log(obj)
445
+ alert('check obj')
446
+ return obj;
447
+ }
405
448
406
449
window.onload = function() {
407
450
var osInfo = os_detect.getVersion();
@@ -418,15 +461,6 @@ def get_detection_html(user_agent)
418
461
"vuln_test" : <%= js_vuln_test %>
419
462
};
420
463
421
- if (d["flash"]) {
422
- // Load SWF for accurate Flash detection
423
- // This SWF needs to send the Flash version info as a POST request to BES sort of like this:
424
- // <%=get_resource.chomp("/")%>/<%=@info_receiver_page%>/
425
- var flashObject = document.createElement("object");
426
- flashObject.setAttribute("data", "Flash location from the @flash_swf instance variable");
427
- document.body.appendChild(flashObject); // Do you actually need to do this?
428
- }
429
-
430
464
<% if os.match(OperatingSystems::Match::WINDOWS) and client == HttpClients::IE %>
431
465
d['office'] = ie_addons_detect.getMsOfficeVersion();
432
466
d['mshtml_build'] = ScriptEngineBuildVersion().toString();
@@ -448,10 +482,30 @@ def get_detection_html(user_agent)
448
482
<% end %>
449
483
<% end %>
450
484
451
- var query = objToQuery(d);
452
- postInfo("<%=get_resource.chomp("/")%>/<%=@info_receiver_page%>/", query, function(){
453
- window.location="<%= get_module_resource %>";
454
- });
485
+ 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:
489
+ var flashObject = createFlashObject('<%=get_resource.chomp("/")%>/<%=@flash_swf%>', {width: 1, height: 1}, {allowScriptAccess: 'always', Play: 'True'});
490
+
491
+ (function loop(){
492
+ console.log('loop: ' + flash_version)
493
+ setTimeout(function(){
494
+ if (do_flash_loop) {
495
+ loop()
496
+ }
497
+ console.log('finally: ' + flash_version)
498
+ if (!isEmpty(flash_version)) {
499
+ d["flash"] = flash_version
500
+ }
501
+ sendInfo(d)
502
+ }, 1000);
503
+ })();
504
+
505
+ document.body.appendChild(flashObject)
506
+ } else {
507
+ sendInfo(d)
508
+ }
455
509
}
456
510
| ) . result ( binding ( ) )
457
511
@@ -485,8 +539,10 @@ def cookie_header(tag)
485
539
end
486
540
487
541
def load_swf_detection
488
- # Your SWF loads here
489
- ''
542
+ path = ::File . join ( Msf ::Config . data_directory , 'flash_detector' , 'detector.swf' )
543
+ swf = ::File . open ( path , 'rb' ) { |f | swf = f . read }
544
+
545
+ swf
490
546
end
491
547
492
548
@@ -514,14 +570,10 @@ def on_request_uri(cli, request)
514
570
send_response ( cli , html , { 'Set-Cookie' => cookie_header ( tag ) } )
515
571
516
572
when /#{ @flash_swf } /
573
+ vprint_status ( "Sending SWF used for Flash detection" )
517
574
swf = load_swf_detection
518
- send_response ( cli , swf )
519
-
520
- when /#{ @flash_receiver_page } /
521
- vprint_status ( "Received information from Flash" )
522
- process_browser_info ( :flash , cli , request )
523
- send_not_found ( cli )
524
-
575
+ send_response ( cli , swf , { 'Content-Type' => 'application/x-shockwave-flash' , 'Cache-Control' => 'no-cache, no-store' , 'Pragma' => 'no-cache' } )
576
+
525
577
when /#{ @info_receiver_page } /
526
578
#
527
579
# The detection code will hit this if Javascript is enabled
0 commit comments