作者在 2009-02-02 17:58:57 发布以下内容
记得以前网上有个“桂林老兵SQL注入点扫描工具”,虽然是黑客工具,但是可以扫描出你的网站有哪些网页可以实施SQL注入,找到这些网页后加入放注入的函数
Function SafeRequest(ParaValue)
ParaValue = Trim(Request(ParaValue))
If ParaValue = "" Then
SafeRequest = ""
Exit Function
End If
'要过滤的字符以","隔开
LockValue = "',Select,Update,Delete,insert,Count(,drop table,truncate,Asc(,Mid(,char(,xp_cmdshell,exec master,net localgroup administrators,And,net user,Or"
LockValue = Split(LockValue, ",")
'判断是否有注入
For i = 0 To UBound(LockValue)
If InStr(LCase(ParaValue), LCase(LockValue(i)))>0 Then
errmsg = 1
Exit For
End If
Next
'注入处理
If errmsg = 1 Then
Response.Write "<script language='javascript'>alert('可疑的SQL注入请求!');window.history.go(-1);</script>"
response.End
Else
SafeRequest = ParaValue
End If
End Function
用法:
比如在做查询时
rs.Open "select * from topic where ID="&SafeRequest(Request("ID"))
这样就可以去除参数里的SQL注入语句
Function SafeRequest(ParaValue)
ParaValue = Trim(Request(ParaValue))
If ParaValue = "" Then
SafeRequest = ""
Exit Function
End If
'要过滤的字符以","隔开
LockValue = "',Select,Update,Delete,insert,Count(,drop table,truncate,Asc(,Mid(,char(,xp_cmdshell,exec master,net localgroup administrators,And,net user,Or"
LockValue = Split(LockValue, ",")
'判断是否有注入
For i = 0 To UBound(LockValue)
If InStr(LCase(ParaValue), LCase(LockValue(i)))>0 Then
errmsg = 1
Exit For
End If
Next
'注入处理
If errmsg = 1 Then
Response.Write "<script language='javascript'>alert('可疑的SQL注入请求!');window.history.go(-1);</script>"
response.End
Else
SafeRequest = ParaValue
End If
End Function
用法:
比如在做查询时
rs.Open "select * from topic where ID="&SafeRequest(Request("ID"))
这样就可以去除参数里的SQL注入语句