zoukankan      html  css  js  c++  java
  • Safe3通用asp防注入代码

    <%

    'Copy Right By Safe3 www.safe3.cn
    if request.querystring<>"" then stopinjection(request.querystring)
    if request.Form<>"" then stopinjection(request.Form)
    if request.Cookies<>"" then stopinjection(request.Cookies) 
    function stopinjection(values)
            dim l_get, l_get2,n_get,regex,IP
     for each n_get in values
      for each l_get in values
       l_get2 = values(l_get)
       set regex = new regexp
       regex.ignorecase = true
       regex.global = true
       regex.pattern = "('|;|\*|declare\s|\sand\s|\sor\s|\sunion\s|\bselect\b|\bupdate\b|\binsert\b|\.\./|\.\.\\)"
       if regex.test(l_get2) then
                                    IP=Request.ServerVariables("HTTP_X_FORWARDED_FOR")
                                    If IP = "" Then
                                      IP=Request.ServerVariables("REMOTE_ADDR")
                                    end if
                                    slog("<br><br>操作IP: "&ip&"<br>操作时间: " & now() & "<br>操作页面:"&Request.ServerVariables("URL")&"<br>提交方式: "&Request.ServerVariables("Request_Method")&"<br>提交参数: "&l_get&"<br>提交数据: "&l_get2)
        Response.Write "Illegal operation!"
                                    Response.end
       end if
       set regex = nothing
      next
     next
    end function

    sub slog(logs)
            dim toppath,fs,Ts,Errorlog
            toppath = Server.Mappath("/log.htm")
                                    Set fs = CreateObject("scripting.filesystemobject")
                                    If Not Fs.FILEEXISTS(toppath) Then
                                        Set Ts = fs.createtextfile(toppath, True)
                                        Ts.close
                                    end if
                                    Set Ts= Fs.OpenTextFile(toppath,1)
                                        Do While Not Ts.AtEndOfStream
                                                 Errorlog = Errorlog  & Ts.ReadLine  & chr(13) & chr(10)
                                        loop
                                        Ts.close
                                        Errorlog =Errorlog & logs
                                        Set Ts= Fs.OpenTextFile(toppath,2)
                                        Ts.writeline (Errorlog)
                                        Ts.Close
    end sub
    %>

  • 相关阅读:
    MongoDB安装&启动
    MongoDB集群搭建
    树与二叉树
    git入门
    MongoDB Java Driver
    Spring整合Junit4
    SQL字符串的数字部分递增
    [求职经历反面教材]4周面试20家,面霸磨成面瘫,仅供初级程序员参考!
    简陋的信息采集方式
    由一个博问学到的SQL查询方法 (一道多对多关系查询的面试题)
  • 原文地址:https://www.cnblogs.com/Safe3/p/1358719.html
Copyright © 2011-2022 走看看