Home > Backend Development > PHP Tutorial > 一个phper 防备xss攻击的基本手段

一个phper 防备xss攻击的基本手段

WBOY
Release: 2016-06-13 11:38:05
Original
966 people have browsed it

一个phper 预防xss攻击的基本手段

Copy after login

xss的本质 html注入 

xxs  cross site script

1,反射性xss  No-persistent XXS

2,存储型xxs   persisitent XXS

3,Dom Based XSS   改变dom节点

参加的xss payload  发起cookie劫持伪造post get

phper 我们可以做得基本防御

1,绝大部分浏览器紧张js 访问HttpOnly 属性的cookie

如:

<?phpheader ("set-cookie:cookie1=test1");header("set-cookie:cookie1=test1;httponly",false);?><script>alert(document.cookie);</script>
Copy after login
只会 显示 cookie=test1

对于php5 setcookie("abc","test",null,null.null,null.null,TURE);//最后一个参数


2,检查输入,检查输出(富文本编辑器)

用htmltntities() ,htmlspecialchars()处理 !

对于输入多使用白名单原则来做判断

同时在js代码中用  JavascriptEncode做转码处理





Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template