当前位置:Gxlcms > PHP教程 > php恶意代码过滤函数_PHP教程

php恶意代码过滤函数_PHP教程

时间:2021-07-01 10:21:17 帮助过:16人阅读

php 恶意代码过滤函数

Public Function DecodeFilter(html, filter)
html=LCase(html)
filter=split(filter,",")
For Each i In filter
Select Case i
Case "SCRIPT" ' 去除所有客户端脚本javascipt,vbscript,jscript,js,vbs,event,...
html = exeRE("(javascript|jscript|vbscript|vbs):", "#", html)
html = exeRE("]*>", "", html)
html = exeRE("on(mouse|exit|error|click|key)", "", html)
Case "TABLE": ' 去除表格


html = exeRE("]*>", "", html)
html = exeRE("]*>", "", html)
html = exeRE("]*>", "", html)
html = exeRE("]*>", "", html)
html = exeRE("]*>", "", html)
Case "CLASS" ' 去除样式类class=""
html = exeRE("(<[^>]+) class=[^ |^>]*([^>]*>)", "$1 $2", html)
Case "STYLE" ' 去除样式style=""
html = exeRE("(<[^>]+) style=""[^""]*""([^>]*>)", "$1 $2", html)
html = exeRE("(<[^>]+) style='[^']*'([^>]*>)", "$1 $2", html)
Case "IMG" ' 去除样式style=""
html = exeRE("]*>", "", html)
Case "XML" ' 去除XML
html = exeRE("<\\?xml[^>]*>", "", html)
Case "NAMESPACE" ' 去除命名空间>>
html = exeRE("<\/?[a-z]+:[^>]*>", "", html)
Case "FONT" ' 去除字体
html = exeRE("]*>", "", html)
html = exeRE("]*>", "", html)
html = exeRE("]*>", "", html)
html = exeRE("]*>", "", html)
Case "MARQUEE" ' 去除字幕
html = exeRE("]*>", "", html)
Case "OBJECT" ' 去除对象
html = exeRE("]*>", "", html)
html = exeRE("]*>", "", html)
'html = exeRE("]*>", "", html)
Case "EMBED"
html = exeRE("]*>", "", html)
Case "DIV" ' 去除对象
html = exeRE("])*>", "$1", html)
html = exeRE("])*>", "$1", html)
Case "ONLOAD" ' 去除样式style=""
html = exeRE("(<[^>]+) onload=""[^""]*""([^>]*>)", "$1 $2", html)
html = exeRE("(<[^>]+) onload='[^']*'([^>]*>)", "$1 $2", html)
Case "ONCLICK" ' 去除样式style=""
html = exeRE("(<[^>]+) onclick=""[^""]*""([^>]*>)", "$1 $2", html)
html = exeRE("(<[^>]+) onclick='[^']*'([^>]*>)", "$1 $2", html)
Case "ONDBCLICK" ' 去除样式style=""
html = exeRE("(<[^>]+) ondbclick=""[^""]*""([^>]*>)", "$1 $2", html)
html = exeRE("(<[^>]+) ondbclick='[^']*'([^>]*>)", "$1 $2", html)

End Select
Next
'html = Replace(html," 'html = Replace(html," 'html = Replace(html," DecodeFilter = html
End Function

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/629754.htmlTechArticlephp 恶意代码过滤函数 Public Function DecodeFilter(html, filter) html=LCase(html) filter=split(filter,,) For Each i In filter Select Case i Case SCRIPT ' 去除所有客户端...

人气教程排行