关于冰盾 | 使用条款 | 网站地图
 
防止SQL注入的函数。
防止SQL注入的函数。
作者:冰盾防火墙 网站:www.bingdun.com 日期:2014-12-03
 

函数名:s_request()


'辅助函数:r_reader()


'作用:过滤非法字符,防止sql注入。


'参数:s_str:被传入的变量的名,类型:字符串


'返回值:过滤后的值。


'**********************************************


const c_sqlstr="',count,user,user,count,1=1,and,2=2" '需要过滤的字符串序列,每个字符串之间用“,”分隔


dim reader


function r_reader(r_str,f_str)
 dim i
 
 if r_str="" or f_str="" then
  exit function
 end if
 
 reader=split(r_str,f_str)
 
 for i=0 to ubound(reader,1)
  reader(i)=cstr(trim(reader(i)))
 next
 r_reader=ubound(reader,1)
end function


function s_request(s_str)
 dim temp,i
  if s_str="" then
   exit function
  end if


  temp=request(s_str)
  for i=0 to r_reader(c_sqlstr,",")
   temp=replace(temp,cstr(reader(i)),"")
  next
   temp=replace(temp,chr(34),"")
   s_request=cstr(trim(temp))
   erase reader
end function


用法:


原来的例如这样的语句:


a=request("a")


现在写成:


a=s_request("a")


即可实现非法字符串过滤。


当然,你也可以写成这样:


function s_request(s_str)
 dim temp,i,temp1
  if s_str="" then
   exit function
  end if


  temp=cstr(request(s_str))
  temp1=temp
  for i=0 to r_reader(c_sqlstr,",")
   temp=replace(temp,cstr(reader(i)),"")
   if temp1<>temp then
    response.write ("请不要输入非法字符!")
    response.end
   end if
  next
   temp=replace(temp,chr(34),"")
   s_request=cstr(trim(temp))
   erase reader
end function


这样,可以返回一个错误报告。


 

 
最新内容:
SQL注入网站入侵实例[2014-12-03]
NTP DDoS攻击激增 而SYN洪水攻击更具破环性[2014-12-02]
Syn Flood 类型攻击的防护[2014-12-02]
剖析"拒绝服务"攻击-SYN拒绝服务[2014-12-02]
Syn Flood攻击是利用TCP/IP协议的什么漏洞[2014-12-02]
Windows Server 2003下SYN Flood攻击防御的一种方法[2014-12-02]
相关内容:

合作伙伴: 黑基网 补天科技 威盾科技 站长下载 新飞金信 北京电信 ZOL应用下载
中华人民共和国增值电信业务经营许可证京ICP备14024464 公安备案号 京1081234 
版权所有©2003-2014 冰盾防火墙  www.BingDun.com 法律声明
总机:(010)51661195