asp 防止SQL注入
2006-06-26 20:21
316 查看
防止SQL注入 古老的话题,不需要太多的解释了,这里给出一个解决办法,
'**********************************
'防止SQL注入程序
'联系:QQ:49934843 EMAIL:cyh.yiheng@gmail.com
'***********************************
dim sql_Chk_Post,sql_Chk_Get,sql_Chk_In,sql_Chk_Inf,sql_Chk_Xh,sql_Chk_db,sql_Chk_dbstr,sql_Chk_Err
sql_Chk_Err = false
sql_Chk_In = "'|;|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare"
sql_Chk_Inf = split(sql_Chk_In,"|")
'--------POST部份------------------
If Request.Form<>"" Then
For Each sql_Chk_Post In Request.Form
For sql_Chk_Xh=0 To Ubound(sql_Chk_Inf)
If Instr(LCase(Request.Form(sql_Chk_Post)),sql_Chk_Inf(sql_Chk_Xh))<>0 Then
sql_Chk_Err = true
alertError(sql_Chk_Post)
End If
Next
Next
End If
'--------GET部份-------------------
If Request.QueryString<>"" Then
For Each sql_Chk_Get In Request.QueryString
For sql_Chk_Xh=0 To Ubound(sql_Chk_Inf)
If Instr(LCase(Request.QueryString(sql_Chk_Get)),sql_Chk_Inf(sql_Chk_Xh))<>0 Then
sql_Chk_Err = true
alertError(sql_Chk_Get)
End If
Next
Next
End If
'-------------------------------------
function alertError(byval sql_Chk_Date)
Response.Write "<Script Language=JavaScript>alert(' SQL通用防注入系统提示↓/n/n请不要在参数中包含非法字符尝试注入!/n/n SQL通用防注入V2.0(ASP)完美版');</Script>"
Response.Write "非法操作!系统做了如下记录↓<br>"
Response.Write "操作IP:"&Request.ServerVariables("REMOTE_ADDR")&"<br>"
Response.Write "操作时间:"&Now&"<br>"
Response.Write "操作页面:"&Request.ServerVariables("URL")&"<br>"
Response.Write "提交参数:"&sql_Chk_Date&"<br>"
Response.Write "提交数据:"&Request(sql_Chk_Date)
Response.End
End function
将以上程序放在一个文件中,并include在自己的程序前,基本上能保证检测到。
'**********************************
'防止SQL注入程序
'联系:QQ:49934843 EMAIL:cyh.yiheng@gmail.com
'***********************************
dim sql_Chk_Post,sql_Chk_Get,sql_Chk_In,sql_Chk_Inf,sql_Chk_Xh,sql_Chk_db,sql_Chk_dbstr,sql_Chk_Err
sql_Chk_Err = false
sql_Chk_In = "'|;|and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare"
sql_Chk_Inf = split(sql_Chk_In,"|")
'--------POST部份------------------
If Request.Form<>"" Then
For Each sql_Chk_Post In Request.Form
For sql_Chk_Xh=0 To Ubound(sql_Chk_Inf)
If Instr(LCase(Request.Form(sql_Chk_Post)),sql_Chk_Inf(sql_Chk_Xh))<>0 Then
sql_Chk_Err = true
alertError(sql_Chk_Post)
End If
Next
Next
End If
'--------GET部份-------------------
If Request.QueryString<>"" Then
For Each sql_Chk_Get In Request.QueryString
For sql_Chk_Xh=0 To Ubound(sql_Chk_Inf)
If Instr(LCase(Request.QueryString(sql_Chk_Get)),sql_Chk_Inf(sql_Chk_Xh))<>0 Then
sql_Chk_Err = true
alertError(sql_Chk_Get)
End If
Next
Next
End If
'-------------------------------------
function alertError(byval sql_Chk_Date)
Response.Write "<Script Language=JavaScript>alert(' SQL通用防注入系统提示↓/n/n请不要在参数中包含非法字符尝试注入!/n/n SQL通用防注入V2.0(ASP)完美版');</Script>"
Response.Write "非法操作!系统做了如下记录↓<br>"
Response.Write "操作IP:"&Request.ServerVariables("REMOTE_ADDR")&"<br>"
Response.Write "操作时间:"&Now&"<br>"
Response.Write "操作页面:"&Request.ServerVariables("URL")&"<br>"
Response.Write "提交参数:"&sql_Chk_Date&"<br>"
Response.Write "提交数据:"&Request(sql_Chk_Date)
Response.End
End function
将以上程序放在一个文件中,并include在自己的程序前,基本上能保证检测到。
相关文章推荐
- asp 防止SQL注入代码
- ASP防止SQL注入方法
- asp利用Parameters对象,实现防止sql注入,执行sql语句并返回变量值
- ASP.NET会员注册登录模块(MD5加密,Parameters防止SQL注入,判断是否注册)
- AOP实践--ASP.NET MVC 5使用Filter过滤Action参数防止sql注入,让你代码安全简洁
- asp.net程序防止sql注入
- 防止asp被SQL注入
- asp.net防止sql注入(转)
- 防止SQL注入ASP代码
- ASP.net防止SQL注入方法
- ASP.NET防止Sql注入的解决方法
- asp.net中过滤非法字符防止SQL注入
- asp.net 防止 sql注入
- ASP防止跨站脚本和SQL注入代码
- asp.net 防止sql注入 global 文件控制
- ASP.NET利用httpHandler 防止SQL注入!
- asp.net 防止 sql注入
- ASP防止SQL注入的问题
- asp.net防止sql注入,删除关键字的一个重要方法
- ASP程序安全-如何防止sql注入