ASP利用session判斷,來實現全面防CC攻擊代碼。
001
<%
002
Dim
CC_Info(4),strInfo,strTemp
003
If
Session(
"CC_Info"
) =
""
Then
004
CC_Info(0) =
"cclog.txt"
'日志文件名
005
CC_Info(1) = Request.ServerVariables(
"HTTP_X_FORWARDED_FOR"
)
006
CC_Info(2) = Request.ServerVariables(
"REMOTE_ADDR"
007
CC_Info(3) = 10
'N秒內禁止刷新當前頁面
008
CC_Info(4) =
"badip.txt"
'IP黑名單文件名
009
) = CC_Info(0) &
"|"
& CC_Info(1) &
& CC_Info(2) &
& CC_Info(3) &
& CC_Info(4)
010
Else
011
strInfo = Split(Session(
),
012
CC_Info(0) = strInfo(0)
013
CC_Info(1) = strInfo(1)
014
CC_Info(2) = strInfo(2)
015
CC_Info(3) = strInfo(3)
016
CC_Info(4) = strInfo(4)
017
End
018
019
Const
chkRefresh = 1
'0關閉防刷新
020
chkProxy = 1
'0關閉代理驗證
021
chkBadIP = 1
'0關閉IP黑名單
022
023
"BadIP"
024
strInfo = ReadFile(CC_Info(4))
025
strInfo =
"chinavb.Net"
026
) = strInfo
027
028
strInfo = Session(
029
030
031
'/*第一層判斷,N秒內禁止刷新*/
032
033
"RefreshTime"
)=
034
)=Now()
035
036
DateDiff(
"s"
, Session(
), Now()) <
CInt
(CC_Info(3))
037
Response.Write(
"系統繁忙,請稍候再試!錯誤代碼001"
038
Response.
()
039
040
041
042
043
044
045
'/*第二層判斷,代理禁止查看*/
046
047
CC_Info(1) <>
048
InStr(strInfo,CC_Info(1)) = 0
049
strTemp = CC_Info(1) & vbCrLf
050
InStr(strInfo,CC_Info(2)) = 0
051
strTemp = strTemp &
"["
"]"
& vbCrLf
052
053
SaveLog CC_Info(4),strTemp
054
strInfo = strInfo & strTemp
055
056
057
'記錄CC攻擊日志
058
SaveLog CC_Info(0),CC_Info(1) &
& Now() &vbCrLf
059
"系統繁忙,請稍候再試!錯誤代碼002"
060
061
062
063
064
'/*第三層判斷,IP黑名單禁止查看*/
065
066
InStr(strInfo,CC_Info(2))>0
067
"系統繁忙,請稍候再試!錯誤代碼003"
068
069
070
071
072
'ForReading=1,ForWriting=2,ForAppending=8
073
Function
SaveLog(filename, filecontent)
074
On
Error
Resume
Next
075
fso, thisfile
076
filename = Server.MapPath(filename)
077
Set
fso = CreateObject(
"Scripting.FileSystemObject"
078
Err <> 0
079
"寫入文件"
&filename&
"失敗,可能您的系統不支持FSO!"
080
081
082
thisfile = fso.OpenTextFile(filename, 8,
True
083
thisfile.write (filecontent)
084
thisfile.Close
085
fso =
Nothing
086
087
088
ReadFile(filename)
089
090
091
092
093
"讀取文件"
094
095
096
thisfile = fso.OpenTextFile(Server.MapPath(filename), 1,
097
ReadFile = thisfile.ReadAll
098
099
thisfile =
100
101
102
%>
盒子模型是CSS中一個重要的概念,理解了盒子模型才能更好的
自從買了PPC以後每
學習目的:學會ACCEES數據庫的使用,並建立一個將來要用
五花八門的SQL產品多得要命,或許你早顧不得其它甩開袖子就
摘要:當收集客戶對Visual Studio&n
雖然Windows 7的正式版還沒有發布,但大家對測試版的