反黑客编码(反XSS编码行为)?
我已经从事 php 编码一年了。我不知道一切,也不认为自己很专业。但我想编写干净的黑客证明代码。我试图研究如何阻止XSS攻击,但似乎有很多表达方式和很多漏洞。我尝试过 htmlawed 和 html 净化器。但并非我编写的每个简单表单或脚本都需要大量脚本来确保其安全。所以我需要的是:是否有一种我可以遵循的编码风格,可以使我的编码安全?
i am into php coding for 1 year now. i don't know everything or consider myself professional.but i want to write clean hacker proof coding. i tried to research for example how to stop XSS attacks.but it seems that there is a lot of expressions and a lot of vulnerabilities. i tried htmlawed and html purifiers. but not every simple form or script i write will need heavy script to make it secure. so what i need is : is there a coding style that i can follow that make my coding secure?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,为了避免 XSS,您必须确保用户无法将 HTML 注入到页面的 HTML 输出中。
最简单的方法是使用诸如
htmlspecialchars()
< 之类的函数/strong> 任何以 HTML 形式发送到浏览器的输出。This means that, if anyone inputs something like this *(simple example)* :
您的页面的 HTML 将包含:
并且没有可以解释的 HTML / Javascript 代码。
Basically, to avoid XSS, you have to make sure no HTML can be injected by the users into the HTML output of your page.
The simplest way of doing that is to use functions such as
htmlspecialchars()
on any output that goes to the browser as HTML.This means that, if anyone inputs something like this *(simple example)* :
The HTML of your page will contain :
And no HTML / Javascript code that could be interpreted.