zl程序教程

您现在的位置是:首页 >  其他

当前栏目

asp终极防范SQL注入漏洞

漏洞ASP注入SQL 终极 防范
2023-06-13 09:14:27 时间
下面给出4个函数,足够你抵挡一切SQL注入漏洞!读懂代码,你就能融会贯通。

注意要对所有的request对象进行过滤:包括request.cookie,request.ServerVariables等等容易被忽视的对象:
复制代码代码如下:

functionkilln(byvals1)"过滤数值型参数
ifnotisnumeric(s1)then
killn=0
else
ifs1<0ors1>2147483647then
killn=0
else
killn=clng(s1)
endif
endif
endfunction

functionkillc(byvals1)过滤货币型参数
ifnotisnumeric(s1)then
killc=0
else
killc=formatnumber(s1,2,-1,0,0)
endif
endfunction

functionkillw(byvals1)"过滤字符型参数
iflen(s1)=0then
killw=""
else
killw=trim(replace(s1,""",""))
endif
endfunction

functionkillbad(byvals1)过滤所有危险字符,包括跨站脚本
Iflen(s1)=0then
killbad=""
else
killbad=trim(replace(replace(replace(replace(replace(replace(replace(replace(s1,Chr(10),"<br>"),Chr(34),"""),">",">"),"<","<"),"&","&"),chr(39),"""),chr(32),""),chr(13),""))
endif
endfunction