• 奇爱公告:
  • 设为首页
  • |
  • 收藏本站
  • |
  • RSS阅读
  • |
  • 网站地图
  • |
  • 站内搜索
  • 奇爱素材网

  • 首页 酷站 PNG 矢量 GIF 笔刷 背景 PSD 欣赏 代码 FLA 教程 图库 书店
  • 您现在的位置: 奇爱素材网 >> 设计教程 >> 网站安全 >> 漏洞补丁 >> 正文 |
  • SQL注入式攻击防范代码

    作者:夏日之夜 素材来源:yada.net 点击数: 更新时间:2007-6-8 21:31:37

     
    SQL注入式攻击防范代码
    --------------------------------------------------------------------------------
    'SQL注入式攻击防范get及ID(not)代码
    squery=lcase(Request.ServerVariables("QUERY_STRING"))
    sURL=lcase(Request.ServerVariables("HTTP_HOST"))
    allquery=squery+sURL
    if InStr(allquery,"%20")<>0 or InStr(allquery,"%27")<>0 or InStr(allquery,"'")<>0 or InStr(allquery,"%a1a1")<>0 or InStr(allquery,"%24")<>0 or InStr(allquery,"%3b")<>0 or InStr(allquery,";")<>0 or InStr(allquery,":")<>0 or InStr(allquery,"%%")<>0 or InStr(allquery,"%3c")<>0 or InStr(allquery,"--")<>0 or InStr(allquery,"")<>0 or InStr(allquery,"*")<>0 or not(isnumeric(request("id"))) or not(isnumeric(request("page"))) then
    Response.write "不法访问"
    Response.End
    end if
    'post过滤sql注入代防范及HTML防护
    function nosql(str)
    if not isnull(str) then
    str=trim(str)
    str=replace(str,";",";") '分号
    str=replace(str,"'","'") '单引号
    str=replace(str,"""",""") '双引号
    str=replace(str,"chr(9)"," ") '空格
    str=replace(str,"chr(10)","<br>") '回车
    str=replace(str,"chr(13)","<br>") '回车
    str=replace(str,"chr(32)"," ") '空格
    str=replace(str,"chr(34)",""") '双引号
    str=replace(str,"chr(39)","'") '单引号
    str=Replace(str, "script", "script")'jscript
    str=replace(str,"<","<") '左<
    str=replace(str,">",">") '右>
    str=replace(str,"--","--") 'SQL注释符
    nosql=str
    end if
    end function
    'post过滤sql注入代防范及HTML防护开始
    function FormatSQL(str)
    if isnull(str) then
    str = ""
    exit function
    end if
    str=trim(str)
    str=replace(str,"&","&amp;") '&
    str=replace(str,";","&#59;") '分号
    str=replace(str,"'","&#39;") '单引号
    str=replace(str,"""","&quot;") '双引号
    str=replace(str,"chr(9)","&nbsp;") '空格
    str=replace(str,"chr(10)","<br>") '回车
    str=replace(str,"chr(13)","<br>") '回车
    str=replace(str,"chr(32)","&nbsp;") '空格
    str=replace(str,"chr(34)","&quot;") '双引号
    str=replace(str,"chr(39)","&#39;") '单引号
    str=Replace(str, "script", "&#115cript")'script
    str=replace(str,"<","&lt;") '左<
    str=replace(str,">","&gt;") '右>
    str=replace(str,"(","&#40;") '左(
    str=replace(str,")","&#41;") '右)
    str=replace(str,"*","&#42;") '*
    str=replace(str,"--","&#45;&#45;") 'SQL注释符
    FormatSQL=str
    end function
  • 上一篇教程: 没有了
  • 下一篇教程: 攻防实战:注入漏洞的利用和防范
    • 提点建议 | 友情链接 | 广告服务 | 免责声明 | 联系我们 | 网站地图 | RSS阅读
      Copyright © 2006-2008 Www.72sc.coM, All Rights Reserved 版权所有 奇爱素材网 鄂ICP备07010427号
      ++技术交流QQ群号码:1226944 ++业务联系QQ:19295971