频道栏目
首页 > 资讯 > 网站安全 > 正文

Safe3通用asp防注入代码

09-01-07        来源:[db:作者]  
收藏   我要投稿

<%

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 = "(|;|*|declares|sands|sors|sunions|select|update|insert|../|..\)"
   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
%>

相关TAG标签
上一篇:注册表及组策略后门实测手札
下一篇:中国游戏视频门户网站GTV 遭遇挂马袭击
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站