上篇文章描述了《如何快速镜像一个网站》,但作为安全工作者,我们的目的是防止网站被镜像。
针对《如何快速镜像一个网站》中描述的镜像网站的方法,本文提出一些防止网站被镜像的方法。
实际上就是防止爬虫的方法,如下方法,供参考。
1、尽量将静态页面调整为动态页面,比如html->jsp、asp、php
2、如果网站基于apache,可以配置阻止user-agent
SetEnvIfNoCase User-Agent "^Wget" bad_bot
SetEnvIfNoCase User-Agent "^Wget/1.5.3" bad_bot
SetEnvIfNoCase User-Agent "^Wget/1.6" bad_bot
<Files ~ "\.(html|pdf|mp3|zip|rar|exe|gif|jpe?g|png|php|jsp) $">
Order Allow,Deny
Allow from all
Deny from env=bad_bot
</files>
3、如果网站基于nginx,可以配置阻止user-agent
## Block http user agent - wget ##
if ($http_user_agent ~* (Wget) ) {
return 403;
}
## Block Software download user agents ##
if ($http_user_agent ~* LWP::Simple|BBBike|wget) {
return 403;
3、在网站根目录放置robots.txt,一般爬虫程序会优先访问robots.txt文件,然后根据规则做进一步处理,比如禁止抓取图片,可配置如下
User-agent: *
Disallow: .jpg$
4、编写脚本,结合web服务器访问log和iptables,如果同一ip在短时间内过于频繁的访问则阻止此ip。
5、购买WAF(web应用防火墙)