我在“symphony CMS”应用程序中找到它,它非常小:
https://github.com/symphonycms/xssfilter/blob/master/extension.driver.php#L100
我正在考虑窃取它并在我自己的应用程序中使用它来使用 HTML 清理字符串以便显示。你觉得它做得好吗?
ps:我知道有 HTML Purifier,但那东西很大。我宁愿选择不那么宽松的东西,但我仍然希望它高效。
我一直在针对此页面中的字符串对其进行测试:http://ha.ckers.org/xss.html .但如果针对“XSS 定位器 2”失败。不确定如何使用该字符串来破解网站 :)
最佳答案
不,我不会使用它。有许多不同的攻击都取决于数据插入的上下文。一项功能无法涵盖所有这些功能。如果仔细观察,实际上只有四个测试:
// Set the patterns we'll test against
$patterns = array(
// Match any attribute starting with "on" or xmlns
'#(<[^>]+[\x00-\x20\"\'\/])(on|xmlns)[^>]*>?#iUu',
// Match javascript:, livescript:, vbscript: and mocha: protocols
'!((java|live|vb)script|mocha):(\w)*!iUu',
'#-moz-binding[\x00-\x20]*:#u',
// Match style attributes
'#(<[^>]+[\x00-\x20\"\'\/])style=[^>]*>?#iUu',
// Match unneeded tags
'#</*(applet|meta|xml|blink|link|style|script|embed|object|iframe|frame|frameset|ilayer|layer|bgsound|title|base)[^>]*>?#i'
);
没有其他测试。除了这些测试未检测到的攻击(假阴性)外,它还可能将某些输入错误地报告为攻击(假阳性)。
因此,与其尝试检测 XSS 攻击,不如确保使用适当的清理。
关于php - xss检测这个功能够用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9341194/