Skip to content

Commit 9116460

Browse files
committed
Add prototype with AS3
1 parent 21e44f2 commit 9116460

File tree

3 files changed

+117
-29
lines changed

3 files changed

+117
-29
lines changed

data/flash_detector/detector.swf

801 Bytes
Binary file not shown.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Code to do flash version detection from ActionScript
3+
4+
* How to build:
5+
1. Use Flex SDK 4.6 / AIRSDK 18
6+
2. Build with: mxmlc -o msf.swf Exploit.as
7+
*/
8+
9+
package
10+
{
11+
import flash.display.Sprite
12+
import flash.external.ExternalInterface
13+
import flash.system.Capabilities
14+
15+
public class Detector extends Sprite
16+
{
17+
18+
public function Detector()
19+
{
20+
var version:String = getVersion()
21+
ExternalInterface.call("setFlashVersion", version)
22+
}
23+
24+
private function getVersion():String
25+
{
26+
try {
27+
var version:String = flash.system.Capabilities.version
28+
version = version.split(/ /)[1]
29+
version = version.replace(/,/g, ".")
30+
return version
31+
} catch (err:Error) {
32+
return ""
33+
}
34+
}
35+
}
36+
}

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

Lines changed: 81 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ def initialize(info={})
9090
@info_receiver_page = rand_text_alpha(5)
9191
@exploit_receiver_page = rand_text_alpha(6)
9292
@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"
9594

9695
register_options(
9796
[
@@ -333,11 +332,6 @@ def process_browser_info(source, cli, request)
333332

334333
# Gathering target info from the detection stage
335334
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)
341335
when :script
342336
# Gathers target data from a POST request
343337
parsed_body = CGI::parse(Rex::Text.decode_base64(request.body) || '')
@@ -394,6 +388,9 @@ def get_detection_html(user_agent)
394388
<%= js_misc_addons_detect %>
395389
<%= js_ie_addons_detect if os.match(OperatingSystems::Match::WINDOWS) and client == HttpClients::IE %>
396390
391+
var flash_version = "";
392+
var do_flash_loop = true;
393+
397394
function objToQuery(obj) {
398395
var q = [];
399396
for (var key in obj) {
@@ -402,6 +399,52 @@ def get_detection_html(user_agent)
402399
return Base64.encode(q.join('&'));
403400
}
404401
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+
}
405448
406449
window.onload = function() {
407450
var osInfo = os_detect.getVersion();
@@ -418,15 +461,6 @@ def get_detection_html(user_agent)
418461
"vuln_test" : <%= js_vuln_test %>
419462
};
420463
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-
430464
<% if os.match(OperatingSystems::Match::WINDOWS) and client == HttpClients::IE %>
431465
d['office'] = ie_addons_detect.getMsOfficeVersion();
432466
d['mshtml_build'] = ScriptEngineBuildVersion().toString();
@@ -448,10 +482,30 @@ def get_detection_html(user_agent)
448482
<% end %>
449483
<% end %>
450484
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+
}
455509
}
456510
|).result(binding())
457511

@@ -485,8 +539,10 @@ def cookie_header(tag)
485539
end
486540

487541
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
490546
end
491547

492548

@@ -514,14 +570,10 @@ def on_request_uri(cli, request)
514570
send_response(cli, html, {'Set-Cookie' => cookie_header(tag)})
515571

516572
when /#{@flash_swf}/
573+
vprint_status("Sending SWF used for Flash detection")
517574
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+
525577
when /#{@info_receiver_page}/
526578
#
527579
# The detection code will hit this if Javascript is enabled

0 commit comments

Comments
 (0)