时间:2021-05-28
用于防止sql注入攻击的 函数,大家可以直接用了,不过大家光会用不行,要增强安全意识
复制代码 代码如下:
'==========================
'过滤提交表单中的SQL
'==========================
functionForSqlForm()
dimfqys,errc,i,items
dimnothis(18)
nothis(0)="netuser"
nothis(1)="xp_cmdshell"
nothis(2)="/add"
nothis(3)="exec%20master.dbo.xp_cmdshell"
nothis(4)="netlocalgroupadministrators"
nothis(5)="select"
nothis(6)="count"
nothis(7)="asc"
nothis(8)="char"
nothis(9)="mid"
nothis(10)="'"
nothis(11)=":"
nothis(12)=""""
nothis(13)="insert"
nothis(14)="delete"
nothis(15)="drop"
nothis(16)="truncate"
nothis(17)="from"
nothis(18)="%"
'nothis(19)="@"
errc=false
fori=0toubound(nothis)
foreachitemsinrequest.Form
ifinstr(request.Form(items),nothis(i))<>0then
response.write("<div>")
response.write("你所填写的信息:"&server.HTMLEncode(request.Form(items))&"<br>含非法字符:"¬his(i))
response.write("</div>")
response.write("对不起,你所填写的信息含非法字符!<ahref=""#""onclick=""history.back()"">返回</a>")
response.End()
endif
next
next
endfunction
'==========================
'过滤查询中的SQL
'==========================
functionForSqlInjection()
dimfqys,errc,i
dimnothis(19)
fqys=request.ServerVariables("QUERY_STRING")
nothis(0)="netuser"
nothis(1)="xp_cmdshell"
nothis(2)="/add"
nothis(3)="exec%20master.dbo.xp_cmdshell"
nothis(4)="netlocalgroupadministrators"
nothis(5)="select"
nothis(6)="count"
nothis(7)="asc"
nothis(8)="char"
nothis(9)="mid"
nothis(10)="'"
nothis(11)=":"
nothis(12)=""""
nothis(13)="insert"
nothis(14)="delete"
nothis(15)="drop"
nothis(16)="truncate"
nothis(17)="from"
nothis(18)="%"
nothis(19)="@"
errc=false
fori=0toubound(nothis)
ifinstr(FQYs,nothis(i))<>0then
errc=true
endif
next
iferrcthen
response.write"查询信息含非法字符!<ahref=""#""onclick=""history.back()"">返回</a>"
response.end
endif
endfunction
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
1、SQL注入攻击的本质:让客户端传递过去的字符串变成SQL语句,而且能够被执行。2、每个程序员都必须肩负起防止SQL注入攻击的责任。 说起防止SQL注入攻击
PHP与SQL注入攻击[二]MagicQuotes上文提到,SQL注入主要是提交不安全的数据给数据库来达到攻击目的。为了防止SQL注入攻击,PHP自带一个功能可
下面通过两个方面给大家介绍js代码防止sql注入的方法,非常简单实用,感兴趣的朋友参考下吧!1.URL地址防注入://过滤URL非法SQL字符varsUrl=l
什么是SQL注入(SQLInjection)所谓SQL注入式攻击,就是攻击者把SQL命令插入到Web表单的输入域或页面请求的查询字符串,欺骗服务器执行恶意的SQ
//GPC过滤,自动转义$_GET,$_POST,$_COOKIE中的特殊字符,防止SQL注入攻击$_GET=saddslashes($_GET);$_POST