• RainbowSoft Studio Z-Blog
  • RainbowSoft Studio Z-Blog
  • 本站支持WAP访问
  • 订阅本站的 RSS 2.0 新闻聚合
Name:密陀僧
Email:sunwindy[A]gmail.com

关于catalog.asp的再续

Post by 密陀僧, 2007-11-12, Views:
今天在群里高温告诉我,zblog论坛有人找我。过去看时原来是前几天发布的Zblog的catalog.asp可被利用发起拒绝服务攻击被zblog的作者zx.asd注意到了,他同时发布了一个c_banip.asp,是05年写的一个banip类,可能因为zblog当时还没有太多人使用,暂时没有用到zblog中。
下面说一下这个banip类的用法
1、在c_system_lib.asp中加入:

'*********************************************************
' 目的:    定义TBanIP类
' 输入:    无
' 返回:    无
'*********************************************************
Class TBanIP

        Public CLSID
        Public Name
        Public Interval
        Public Length

        Private IpList()
        Private TimeList()

        Private IpNow
        Private TimeNow

        Private Function ChangeTimeToInteger(dtmTime)
                ChangeTimeToInteger=(Year(dtmTime)*60*60*24*30*365 + Month(dtmTime)*60*60*24*30 + Day(dtmTime)*60*60*24 + Hour(dtmTime)*60*60 + Minute(dtmTime)*60 + Second(dtmTime))*1000
        End Function

        Public Function LoadList()

                Dim i

                Dim aryIpList
                Dim aryTimeList

                Application.Lock

                aryIpList=Application(CLSID & Name & "IpList")
                aryTimeList=Application(CLSID & Name & "TimeList")

                Application.UnLock

                ReDim Preserve IpList(Length)
                ReDim Preserve TimeList(Length)

                If IsArray(aryIpList) Then

                        For i=0 to Length
                                IpList(i)=aryIpList(i)
                                TimeList(i)=aryTimeList(i)
                        Next

                Else
                End If


        End Function

        Public Function SaveList()

                Application.Lock

                Application(CLSID & Name & "IpList")=IpList
                Application(CLSID & Name & "TimeList")=TimeList

                Application.UnLock

        End Function

        Private Function ClearList()

                Dim i
                Dim j

                For i=0 To Length
                        If TimeNow-TimeList(i)>Interval Then
                                IpList(i)=Empty
                                TimeList(i)=0
                                j=i
                        End If
                Next

                For i=j+1 To Length
                        IpList(i-j-1)=IpList(i)
                        TimeList(i-j-1)=TimeList(i)
                        IpList(i)=Empty
                        TimeList(i)=0
                Next

        End Function

        Public Function Check(strIP)

                Dim i

                IpNow=strIP
                TimeNow=ChangeTimeToInteger(Now())

                ClearList()

                For i=0 to Length
                        If Not IsEmpty(IpList(i)) Then
                                If IpList(i)=IpNow Then Check=False
                                Exit Function
                        End If
                Next

                For i=0 to Length
                        If IsEmpty(IpList(i)) Then
                                IpList(i)=IpNow
                                TimeList(i)=TimeNow
                                Check=True
                                Exit Function
                        End If
                Next

                For i=0 to Length-1
                        IpList(i)=IpList(i+1)
                        TimeList(i)=TimeList(i+1)
                Next
                IpList(Length)=IpNow
                TimeList(Length)=TimeNow
                Check=True

        End Function

        Private Sub Class_Initialize()

        End Sub

        Private Sub Class_Terminate()

        End Sub

End Class
'*********************************************************2、在c_system_base.asp的Sub System_Initialize()中加入引用:
        
   Dim BanIP
         
   If BlogUser.Level>2 Then '如非管理员则做防刷限制
        Set BanIP=New TBanIP
        
        BanIP.CLSID=ZC_BLOG_CLSID
        BanIP.Name="防刷catalog" '随便起个名字
        BanIP.Length=50 '队列的长度,可以记住50个不同的IP
        BanIP.Interval=1000 '时间间隔,单位是毫秒
        
        BanIP.LoadList
        
        If BanIP.Check(Request.ServerVariables("LOCAL_ADDR"))=False Then
          '如果当前IP出现在这个列表里,说明它在规定时间内重复出现了
          Call ShowError(0)
        End If
        
        BanIP.SaveList
        
        Set BanIP=Nothing
   End If

放在

        Set BlogUser =New TUser
        BlogUser.Verify()

之下

==============================神奇的休止符================================
Tags: catalog.asp  zx.asd  zblog 
分类:技术 | 评论:0 | 引用:0 | 点击这里获取该日志的TrackBack引用地址
上一篇:太搞笑了,原来交友还有这样的方式
下一篇:feedsky果然是系统出bug啊

或许你还对下面的文章感兴趣

Comments

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

Hot Articles

New Articles

Last Comments

Guest