XSS 全称为 Cross Site Scripting,用户在表单中有意或无意输入一些恶意字符,从而破坏页面的表现!

看看常见的恶意字符XSS 输入:

1.XSS 输入通常包含 JavaScript 脚本,如弹出恶意警告框:<script>alert("XSS");</script>

2.XSS 输入也可能是 HTML 代码段,譬如:

(1).网页不停地刷新 <meta http-equiv="refresh" content="0;">

(2).嵌入其它网站的链接 <iframe src=http://xxxx width=250 height=250></iframe>

    <?PHP
/**
* @blog http://www.phpddt.com
* @param $string
* @param $low 安全别级低
*/
function clean_xss(&$string, $low = False)
{
if (! is_array ( $string ))
{
$string = trim ( $string );
$string = strip_tags ( $string );
$string = htmlspecialchars ( $string );
if ($low)
{
return True;
}
$string = str_replace ( array ('"', "\\", "'", "/", "..", "../", "./", "//" ), '', $string );
$no = '/%0[0-8bcef]/';
$string = preg_replace ( $no, '', $string );
$no = '/%1[0-9a-f]/';
$string = preg_replace ( $no, '', $string );
$no = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S';
$string = preg_replace ( $no, '', $string );
return True;
}
$keys = array_keys ( $string );
foreach ( $keys as $key )
{
clean_xss ( $string [$key] );
}
}
//just a test
$str = 'phpddt.com<meta http-equiv="refresh" content="0;">';
clean_xss($str); //如果你把这个注释掉,你就知道xss攻击的厉害了
echo $str;
?>

最新文章

  1. 【微信SEO】公众号也能做排名?
  2. python之函数
  3. Dom4jUtils.java
  4. maven + eclipse + tomcat热部署
  5. C# Datatable排序
  6. 【转载】小米2进入recovery的方法
  7. android 项目学习随笔十七(ListView、GridView显示组图)
  8. 基于IIS的HTTP、FTP文件服务器搭建与性能测试
  9. nodejs 文件上传
  10. C#学习笔记5:数据类型与进制转换
  11. 一款好看+极简到不行的HTML5音乐播放器-skPlayer
  12. linux下 文件IO 相关
  13. java 基础知识三 java变量
  14. Mysql 用户,权限管理的几点理解。
  15. 前端教程(1)http协议的深刻理解
  16. 其它综合-运维老鸟分享linux运维发展路线规划
  17. FontAwesome图标选择器
  18. HOOK NTFS 禁止格式化
  19. 利用shell脚本远程登录服务器并修改saltstack配置并重启服务
  20. Python学习笔记(二):条件控制语句与循环语句及常用函数的用法

热门文章

  1. input file类型,文件类型的限制
  2. ibatis基础
  3. 通过CoreImage生成二维码
  4. submit回车提交影响
  5. Js练习题之查找字符串中出现最多的字符和个数
  6. elasticsearch nested查询
  7. EntityFramework之创建数据库及基本操作(一)
  8. 基于百度定位及天气获取的DEMO
  9. 关于Integer缓冲
  10. RAD,V模型