但最重要的一点,还是那句话强烈的网络安全防护意识和良好的代码书写习惯!
完了,说的太多了,没分,很不爽!
这是以前写的两个防注入函数,希望帮到你!''' <summary>''' 过滤特殊字符,以防止脚本攻击(如:[ ' " : + % { } ])
''' </summary>
''' <param name="anychar">字符串表达式</param>
''' <returns>御凯过滤后的字符串</returns>
''' <remarks>只用于将字符串存入数据库的时候使用</remarks>
Public Function A_Incode(ByVal anychar As String) As String
'过滤SQL注入"
anychar = anychar.Replace("镇岁唤""", "ぁ")
'过滤SQL注入'
anychar = anychar.Replace("'", "ぃ")
'过滤SQL注入[
anychar = anychar.Replace("[", "ぅ")
'过滤SQL注入]
anychar = anychar.Replace("]", "ぇ")
'过滤SQL注入%
anychar = anychar.Replace("%", "ぉ")
'过滤SQL注入:
anychar = anychar.Replace(":", "か")
'过滤SQL注入
anychar = anychar.Replace("", "き")
'过滤SQL注入+
anychar = anychar.Replace("+", "く")
'过滤SQL注入{
anychar = anychar.Replace("{", "け")
'过滤SQL注入}
anychar = anychar.Replace("}", "こ")
Return (anychar)
End Function
''' <summary>
''' 还原过滤的特殊字符,已显示正确的内容(如:[ ' " : + % { } ])
''' </summary>
''' <param name="anychar">字符串表达式</param>
''' <returns>过滤后的字符串</returns>
''' <remarks>只用于将字符串存入雀好数据库的时候使用</remarks>
Public Function A_Outcode(ByVal anychar As String) As String
'过滤SQL注入"
anychar = anychar.Replace("ぁ", """")
'过滤SQL注入'
anychar = anychar.Replace("ぃ", "'")
'过滤SQL注入[
anychar = anychar.Replace("ぅ", "[")
'过滤SQL注入]
anychar = anychar.Replace("ぇ", "]")
'过滤SQL注入%
anychar = anychar.Replace("ぉ", "%")
'过滤SQL注入:
anychar = anychar.Replace("か", ":")
'过滤SQL注入
anychar = anychar.Replace("き", "")
'过滤SQL注入+
anychar = anychar.Replace("く", "+")
'过滤SQL注入{
anychar = anychar.Replace("け", "{")
'过滤SQL注入}
anychar = anychar.Replace("こ", "}")
Return (anychar)
End Function
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)