前幾天看 Apache log 時,發現了一個奇怪的現象:
* - - [21/Apr/2010:13:21:41 +0800] "GET *** HTTP/1.1" 206 65911 "***" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"
Log 出現很多抓這個檔案的 Entry,不過這檔案並沒有公開的連結,而且 User-Agent 都一樣。用這裡的 script 統計之後發現這個 User-Agent 佔了很大一部分:
# cat /var/log/apache2/access.log | awk -F\" '{A[$(NF-1)]++}END{for(k in A)print A[k],k}' | sort -n | tail
672 Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB6.4; SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.30729)
754 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
1080 Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)
1092 Mozilla/5.0 (compatible; Yahoo! Slurp/3.0; http://help.yahoo.com/help/us/ysearch/slurp)
1579 Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.1.249.1045 Safari/532.5
2003 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.1.249.1045 Safari/532.5
2017 Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
2778 Microsoft-IIS/0.0 (internal dummy connection)
13463 Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
26297 Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)
找了一些資料以後,果然和我猜測的一樣,是迅雷在搞鬼(因為看到很多 IP 都是大陸來的):
照上面的方法用 mod_rewrite 把它的 User-Agent 檔掉,雖然 User-Agent 不可靠,現在要檔他只能用這種方法了。
RewriteEngine On
#Anti Thunder (Xunlei)
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4\.0\ \(compatible;\ MSIE\ 6\.0;\ Windows\ NT\ 5\.1\)$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4\.0\ \(compatible;\ MSIE\ 6\.0;\ Windows\ NT\ 5\.0\)$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/5\.0\ \(compatible;\ MSIE\ 6\.0;\ Windows\ NT\ 5\.0\)$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4\.0\ \(compatible;\ MSIE\ 6\.0;\ Windows\ NT\ 5\.1;\ \)$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4\.0\ \(compatible;\ MSIE\ 6\.0;\ Windows\ NT\ 5\.0;\ \.NET\ CLR\ 3\.5\.20706\)$ [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/4\.0\ \(compatible;\ MSIE\ 6\.0;\ Windows\ NT\ 5\.1;\ SV1;\ \.NET\ CLR\ 1\.1\.4322;\ \.NET\ CLR\ 2\.0\.50727\)$ [NC]
RewriteRule ^.*\.(gif|jpg|bmp|zip|rar|exe|mp3|swf)$ / [NC,F]
0 意見:
張貼意見