您现在的位置是:网站首页> 编程资料编程资料
asp终极防范SQL注入漏洞_应用技巧_
                     2023-05-25
                253人已围观
                
                2023-05-25
                253人已围观
            
简介 asp终极防范SQL注入漏洞_应用技巧_
                下面给出4个函数,足够你抵挡一切SQL注入漏洞!读懂代码,你就能融会贯通。 
注意要对所有的request对象进行过滤:包括 request.cookie, request.ServerVariables 等等容易被忽视的对象:
function killn(byval s1) '过滤数值型参数
if not isnumeric(s1) then
killn=0
else
if s1<0 or s1>2147483647 then
killn=0
else
killn=clng(s1)
end if
end if
end function
function killc(byval s1) 过滤货币型参数
if not isnumeric(s1) then
killc=0
else
killc=formatnumber(s1,2,-1,0,0)
end if
end function
function killw(byval s1) '过滤字符型参数
if len(s1)=0 then
killw=""
else
killw=trim(replace(s1,"'",""))
end if
end function
function killbad(byval s1) 过滤所有危险字符,包括跨站脚本
If len(s1) = 0 then
killbad=""
else
killbad = trim(replace(replace(replace(replace(replace(replace(replace(replace(s1,Chr(10), "
"), Chr(34), """), ">", ">"), "<", "<"), "&", "&"),chr(39),"'"),chr(32)," "),chr(13),""))
end if
end function
        注意要对所有的request对象进行过滤:包括 request.cookie, request.ServerVariables 等等容易被忽视的对象:
复制代码 代码如下:
function killn(byval s1) '过滤数值型参数
if not isnumeric(s1) then
killn=0
else
if s1<0 or s1>2147483647 then
killn=0
else
killn=clng(s1)
end if
end if
end function
function killc(byval s1) 过滤货币型参数
if not isnumeric(s1) then
killc=0
else
killc=formatnumber(s1,2,-1,0,0)
end if
end function
function killw(byval s1) '过滤字符型参数
if len(s1)=0 then
killw=""
else
killw=trim(replace(s1,"'",""))
end if
end function
function killbad(byval s1) 过滤所有危险字符,包括跨站脚本
If len(s1) = 0 then
killbad=""
else
killbad = trim(replace(replace(replace(replace(replace(replace(replace(replace(s1,Chr(10), "
"), Chr(34), """), ">", ">"), "<", "<"), "&", "&"),chr(39),"'"),chr(32)," "),chr(13),""))
end if
end function
您可能感兴趣的文章:
                
                - access数据库的一些少用操作,ASP,创建数据库文件,创建表,创建字段,ADOX
- ASP ACCESS 日期操作语句小结 By Stabx
- asp 获取access系统表,查询等操作代码
- Asp 操作Access数据库时出现死锁.ldb的解决方法
- asp.net(C#) Access 数据操作类
- asp实现的查询某关键词在MSSQL数据库位置的代码
- asp 在线备份与恢复sqlserver数据库的代码
- asp连接mysql数据库详细实现代码
- asp连接access、sql数据库代码及数据库操作代码
- asp操作access提示无法从指定的数据表中删除原因分析及解决
- ASP中巧用Split()函数生成SQL查询语句的实例
- asp执行带参数的sql语句实例
- ASP 连接 SQL SERVER 2008的方法
- ASP通过ODBC连接SQL Server 2008数据库的方法
- ASP语言实现对SQL SERVER数据库的操作
 
                                
                                                         
                                
                                                         
                                
                                                         
 
    