asp

位置:IT落伍者 >> asp >> 浏览文章

asp防CC攻击代码分享


发布日期:2023年05月08日
 
asp防CC攻击代码分享

<%
Dim CC_Info()strInfostrTemp
If Session("CC_Info") = "" Then
CC_Info() = "cclogtxt" 日志文件名
CC_Info() = RequestServerVariables("HTTP_X_FORWARDED_FOR")
CC_Info() = RequestServerVariables("REMOTE_ADDR")
CC_Info() = N秒内禁止刷新当前页面
CC_Info() = "badiptxt" IP黑名单文件名
Session("CC_Info")  = CC_Info() &"|"& CC_Info() &"|"& CC_Info()  &"|"& CC_Info() &"|"& CC_Info()
Else
strInfo = Split(Session("CC_Info")"|")
CC_Info() = strInfo()
CC_Info() = strInfo()
CC_Info() = strInfo()
CC_Info() = strInfo()
CC_Info() = strInfo()
End If

Const chkRefresh = 关闭防刷新
Const chkProxy = 关闭代理验证
Const chkBadIP = 关闭IP黑名单

If Session("BadIP") = "" Then
strInfo = ReadFile(CC_Info())
If strInfo = "" Then strInfo = "chinavbnet"
Session("BadIP") = strInfo
Else
strInfo = Session("BadIP")
End If

/*第一层判断N秒内禁止刷新*/
If chkRefresh = Then
If Session("RefreshTime")="" Then
Session("RefreshTime")=Now()
Else
If DateDiff("s" Session("RefreshTime") Now()) < CInt(CC_Info()) Then
ResponseWrite("系统繁忙请稍候再试!错误代码")
ResponseEnd()
Else
Session("RefreshTime")=Now()
End If
End If
End If

/*第二层判断代理禁止查看*/
If chkProxy = Then
If CC_Info() <> "" Then
If InStr(strInfoCC_Info()) = Then
strTemp = CC_Info() & vbCrLf
If InStr(strInfoCC_Info()) = Then
strTemp = strTemp & "[" & CC_Info() & "]" & vbCrLf
End If
SaveLog CC_Info()strTemp
strInfo = strInfo & strTemp
Session("BadIP") = strInfo
End If
记录CC攻击日志
SaveLog CC_Info()CC_Info() & "["& CC_Info() & "]" & Now() &vbCrLf
ResponseWrite("系统繁忙请稍候再试!错误代码")
ResponseEnd()
End If
End If

/*第三层判断IP黑名单禁止查看*/
If chkBadIP = Then
If InStr(strInfoCC_Info())> Then
ResponseWrite("系统繁忙请稍候再试!错误代码")
ResponseEnd()
End If
End If

ForReading=ForWriting=ForAppending=
Function SaveLog(filename filecontent)
On Error Resume Next
Dim fso thisfile
filename = ServerMapPath(filename)
Set fso = CreateObject("ScriptingFileSystemObject")
If Err <> Then
ResponseWrite("写入文件"&filename&"失败可能您的系统不支持FSO!")
ResponseEnd()
End If
Set thisfile = fsoOpenTextFile(filename True)
thisfilewrite (filecontent)
thisfileClose
Set fso = Nothing
End Function

Function ReadFile(filename)
On Error Resume Next
Dim fso thisfile
Set fso = CreateObject("ScriptingFileSystemObject")
If Err <> Then
ResponseWrite("读取文件"&filename&"失败可能您的系统不支持FSO!")
ResponseEnd()
End If
Set thisfile = fsoOpenTextFile(ServerMapPath(filename) True)
ReadFile = thisfileReadAll
thisfileClose
Set thisfile = Nothing
Set fso = Nothing
End Function
%>

               

上一篇:asp 随机读取N条记录sql语句

下一篇:ASP 操作cookies保存删除实例