mitchellkrogza/apache-ultimate-bad-bot-blocker

GitHub: mitchellkrogza/apache-ultimate-bad-bot-blocker

一个功能全面、持续更新的Apache黑名单配置集,用于在服务器层面拦截恶意爬虫、垃圾引荐和漏洞扫描。

Stars: 950 | Forks: 199

Apache Ultimate Bad Bot, User-Agent and Spam Referrer Blocker - Apache Block Bad Bots, User-Agents, Vulnerability Scanners, Malware, Adware, Ransomware, Malicious Sites, Spam Referrers, Bad Referrers, Spam Blocker, Porn Blocker, Gambling Blocker,  Wordpress Theme Detector Blocking and Fail2Ban Jail for Repeat Offenders # Apache 恶意 Bot 与 User-Agent 拦截器、垃圾 Referrer 拦截器、恶意 IP 拦截器及 Wordpress 主题检测拦截器 ##### 终极 Apache (2.2 > 2.4+) 恶意 Bot、User-Agent、垃圾 Referrer 拦截器,Adware、Malware 和 Ransomware 拦截器,Clickjacking 拦截器,点击重定向拦截器,SEO 公司和恶意 IP 拦截器,配备 Anti DDOS 系统、Nginx 速率限制和 Wordpress 主题检测拦截。阻止并拦截各类恶意互联网流量,使其无法到达您的网站。[请参阅:恶意 Bot 定义](#define-bad-bots) #### 版本:V3.2026.03.2551 #### 恶意 Referrer 数量:[7108](https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/_generator_lists/bad-referrers.list) #### 恶意 Bot 数量:[683](https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/_generator_lists/bad-user-agents.list) #### 伪装 Googlebot 数量:[218](https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/_generator_lists/fake-googlebots.list) - 创建者:https://github.com/mitchellkrogza - 版权所有 Mitchell Krog ## 拦截器的两个版本?请注意 :exclamation: :exclamation:**此拦截器现在有两个截然不同的版本。**:exclamation: **Apache 2.2 > 2.4+ (access_compat) [ 已在 APACHE 2.2 > 2.4.27 上测试 ]** ``` A Version for Apache 2.2 > 2.4 + which requires the module access_compat and uses the older Order Allow,Deny Access Control Methods. This is the ORIGINAL VERSION of the blocker and is now located in the folder Apache_2.2 at: https://github.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/tree/master/Apache_2.2 ``` **仅限 Apache 2.4+ [ 已在 APACHE 2.4 > 2.4.34 上测试 ]** ``` A new version for Apache 2.4+ only which uses new the Access Control Structures of and . Anyone using Apache 2.4 should be using this new version as it fully complies with the new Access Control Methods of Apache and does not require the access_compat module to be loaded. This new version is at: https://github.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/tree/master/Apache_2.4 ``` ### 支持、贡献与想法交流 请确保您已订阅 Github 通知,以便在拦截器更新或发生任何重要或关键任务(可能导致破坏性)变更时收到通知。 # 配置 APACHE 恶意 BOT 拦截器: - CPANEL 用户请阅读 - https://github.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/blob/master/_CPanel_Instructions/README.md - 无法运行完整 Bot 拦截器的用户请阅读 - https://github.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/blob/master/_htaccess_versions/README.md - 包含用于在 Google Analytics 中创建过滤器/细分(参见下方说明)的 google-exclude.txt 文件的创建 - 包含用于 Google Webmaster Tools 的 google-disavow.txt 文件的创建(参见下方说明) - 包含适用于没有其 Apache 服务器 Root 权限的用户的 .htaccess 和 robots.txt 文件。 Apache Bad Bot Blocker **从仓库复制 GLOBALBLACKLIST.CONF 文件** $APACHE_CONF 通常位于 /etc/apache2 或 /etc/httpd,具体取决于操作系统 将 **globalblacklist.conf** 的内容复制到您的 $APACHE_CONF/custom.d 文件夹中。 例如,Ubuntu/Debian 上的 /etc/apache2/custom.d RHEL/centos 上的 /etc/httpd **您需要创建此文件夹。** 以下说明以 /etc/apache2 为例。 `sudo mkdir /etc/apache2/custom.d` `sudo wget https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.2/custom.d/globalblacklist.conf -O /etc/apache2/custom.d/globalblacklist.conf` 如果您的 Linux 发行版没有 wget,可以使用 curl 替换 wget 命令,如下所示: `curl -sL https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.2/custom.d/globalblacklist.conf -o /etc/apache2/custom.d/globalblacklist.conf` **将您自己的所有域名和 IP 地址列入白名单** 将您自己的所有域名和 IP 地址列入白名单。**请注意重要变更**,现在通过包含文件来完成此操作,这样您就不必在每次更新时重新插入您列入白名单的域名和 IP 地址。 :exclamation: :exclamation: :exclamation: 警告:请勿在 whitelist-ips.conf 中使用 127.0.0.1 作为白名单 IP 地址,这会导致拦截器停止工作。 - 将 whitelist-ips.conf 文件复制到该文件夹中 `sudo wget https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.2/custom.d/whitelist-ips.conf -O /etc/apache2/custom.d/whitelist-ips.conf` - 将 whitelist-domains.conf 文件复制到同一文件夹中 `sudo wget https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.2/custom.d/whitelist-domains.conf -O /etc/apache2/custom.d/whitelist-domains.conf` 使用 nano、vim 或任何其他文本编辑器编辑 whitelist-ips.conf 和 whitelist-domains.conf,以包含您希望从拦截器脚本中特别列入白名单的所有自有域名和 IP 地址。 现在,在拉取任何未来的更新时,您只需拉取最新的 globalblacklist.conf 文件,它会自动包含您列入白名单的域名和 IP 地址。不再需要记住自己手动执行此操作。 **下载用于 IP 地址和 IP 段拦截的自定义黑名单包含文件** 将您希望拒之门外的任何 IP 地址或 IP 段列入黑名单。**请注意重要变更**,现在通过包含文件来完成此操作,以便您完全控制从 Apache 服务器拦截哪些 IP 地址和 IP 段。 - 将 blacklist-ips.conf 文件复制到该文件夹中 `sudo wget https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.2/custom.d/blacklist-ips.conf -O /etc/apache2/custom.d/blacklist-ips.conf` 使用 nano、vim 或任何其他文本编辑器根据需要编辑 blacklist-ips.conf 文件。 现在,在拉取任何未来的更新时,您的自定义 IP 黑名单将不会被覆盖。 **下载用于自定义扫描恶意关键词的恶意 Referrer 词库包含文件** 扫描您希望拒之门外的任何恶意 Referrer 关键词。**请注意重要变更**,现在通过包含文件来完成此操作,以便您完全控制从 Apache 服务器拦截哪些 IP 地址和 IP 段。 - 将 bad-referrer-words.conf 文件复制到该文件夹中 `sudo wget https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.2/custom.d/bad-referrer-words.conf -O /etc/apache2/custom.d/bad-referrer-words.conf` 使用 nano、vim 或任何其他文本编辑器根据需要编辑 bad-referrer-words.conf 文件。 现在,在拉取任何未来的更新时,您的自定义恶意 Referrer 词库将不会被覆盖。 **下载用于自定义拦截 User-Agent 的自定义黑名单 User-Agent 包含文件** 允许您使用此新的包含文件添加您自己的自定义 User-Agent 列表。 - 将 blacklist-user-agents.conf 文件复制到该文件夹中 `sudo wget https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.2/custom.d/blacklist-user-agents.conf -O /etc/apache2/custom.d/blacklist-user-agents.conf` **注意:** 在 Apache Blocker 上,如果您想覆盖任何列入白名单的 Bot,可以将它们添加到此包含文件中,拦截器中之前列入白名单的 Bot 将被此包含文件覆盖。因此,假设出于某种“莫名其妙”的原因,您确实不希望 Googlebot 或 Bingbot 等任何搜索引擎访问或索引您的站点,您可以将它们添加到 blacklist-user-agents.conf 中,它们将被从拦截器中先前的白名单状态覆盖。这现在赋予用户对拦截器的完全控制权,而无需尝试修改 globalblacklist.conf 文件。因此,现在您可以自定义所有包含文件,并且仍然可以拉取 globalblacklist.conf 的每日更新,这不会触及您的任何自定义包含文件。 **包含 GLOBALBLACKLIST.CONF** 在目录块的开头,即在您的 Options 开启语句之后、其余主机配置之前,包含 globalblacklist.conf 文件,示例见下文。**删除 "<<<<<< This needs to be added" 部分** ``` ServerName local.dev DocumentRoot /var/www/html ErrorLog /tmp/error.log Options +Includes Options +FollowSymLinks -Indexes Include custom.d/globalblacklist.conf ``` 如果您在虚拟主机配置之后放置以下配置,则可以全局(针对所有虚拟主机)包含 globalblacklist.conf。 ``` # ###################################### # GLOBAL! deny bad bots and IP addresses # ###################################### # # should be set after s see https://httpd.apache.org/docs/2.4/sections.html#merging # AND-combine with preceding configuration sections AuthMerging And # include black list Include custom.d/globalblacklist.conf ``` **测试您的 APACHE 配置** 执行一次 Apache2 配置测试 `sudo apache2ctl configtest` 如果您没有收到错误,说明您遵循了我的说明,现在您可以通过简单的操作使拦截器生效。 `sudo service apache2 reload` 或者 `sudo service httpd reload` 拦截器现在处于活动和工作状态,因此您现在可以从另一台 Linux 机器运行一些简单的测试以确保其正常工作。 **测试** 从另一台 Linux 机器上的终端针对您自己的域名依次运行以下命令。 **将下面示例中的 yourdomain.com 替换为您的真实域名** `curl -A "googlebot" http://yourdomain.com` 应响应 200 OK `curl -A "80legs" http://yourdomain.com` `curl -A "masscan" http://yourdomain.com` 应响应 403 Forbidden `curl -I http://yourdomain.com -e http://100dollars-seo.com` `curl -I http://yourdomain.com -e http://zx6.ru` 应响应 403 Forbidden Apache Ultimate Bot Blocker 现在正在工作并保护您的网站!!! **更新 APACHE 恶意 BOT 拦截器** 现在得益于自动包含您自己的域名的功能,变得非常简单。 更新到最新版本现在非常简单: `sudo wget https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.2/custom.d/globalblacklist.conf -O /etc/apache2/custom.d/globalblacklist.conf` `sudo apache2ctl configtest` `sudo service apache2 reload` 您将更新到最新版本,并且您的所有白名单域名都会自动包含在内。 # 使用 CRON 自动更新: 请参阅由 Luke Taylor @lutaylor 贡献的适用于 Apache 2.2 和 2.4 的最新自动更新 bash 脚本,地址: https://github.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/blob/master/update-apacheblocker.sh 现在放松一下,晚上睡个好觉,因为您知道您的站点正在告诉所有那些坏家伙“禁止访问”!!! Apache 2.4 Bad Bot Blocker **从仓库复制 GLOBALBLACKLIST.CONF 文件** $APACHE_CONF 通常位于 /etc/apache2 或 /etc/httpd,具体取决于操作系统 将 **globalblacklist.conf** 的内容复制到您的 $APACHE_CONF/custom.d 文件夹中。 例如,Ubuntu/Debian 上的 /etc/apache2/custom.d RHEL/centos 上的 /etc/httpd **您需要创建此文件夹。** 以下说明以 /etc/apache2 为例。 `sudo mkdir /etc/apache2/custom.d` `sudo wget https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.4/custom.d/globalblacklist.conf -O /etc/apache2/custom.d/globalblacklist.conf` 如果您的 Linux 发行版没有 wget,可以使用 curl 替换 wget 命令,如下所示: `curl -sL https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.4/custom.d/globalblacklist.conf -o /etc/apache2/custom.d/globalblacklist.conf` **将您自己的所有域名和 IP 地址列入白名单** 将您自己的所有域名和 IP 地址列入白名单。**请注意重要变更**,现在通过包含文件来完成此操作,这样您就不必在每次更新时重新插入您列入白名单的域名和 IP 地址。 :exclamation: :exclamation: :exclamation: 警告:请勿在 whitelist-ips.conf 中使用 127.0.0.1 作为白名单 IP 地址,这会导致拦截器停止工作。 - 将 whitelist-ips.conf 文件复制到该文件夹中 `sudo wget https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.4/custom.d/whitelist-ips.conf -O /etc/apache2/custom.d/whitelist-ips.conf` - 将 whitelist-domains.conf 文件复制到同一文件夹中 `sudo wget https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.4/custom.d/whitelist-domains.conf -O /etc/apache2/custom.d/whitelist-domains.conf` 使用 nano、vim 或任何其他文本编辑器编辑 whitelist-ips.conf 和 whitelist-domains.conf,以包含您希望从器脚本中特别列入白名单的所有自有域名和 IP 地址。 现在,在拉取任何未来的更新时,您只需拉取最新的 globalblacklist.conf 文件,它会自动包含您列入白名单的域名和 IP 地址。不再需要记住自己手动执行此操作。 **下载用于 IP 地址和 IP 段拦截的自定义黑名单包含文件** 将您希望拒之门外的任何 IP 地址或 IP 段列入黑名单。**请注意重要变更**,现在通过包含文件来完成此操作,以便您完全控制从 Apache 服务器拦截哪些 IP 地址和 IP 段。 - 将 blacklist-ips.conf 文件复制到该文件夹中 `sudo wget https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.4/custom.d/blacklist-ips.conf -O /etc/apache2/custom.d/blacklist-ips.conf` 使用 nano、vim 或任何其他文本编辑器根据需要编辑 blacklist-ips.conf 文件。 现在,在拉取任何未来的更新时,您的自定义 IP 黑名单将不会被覆盖。 **下载用于自定义扫描恶意关键词的恶意 Referrer 词库包含文件** 扫描您希望拒之门外的任何恶意 Referrer 关键词。**请注意重要变更**,现在通过包含文件来完成此操作,以便您完全控制从 Apache 服务器拦截哪些 IP 地址和 IP 段。 - 将 bad-referrer-words.conf 文件复制到该文件夹中 `sudo wget https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.4/custom.d/bad-referrer-words.conf -O /etc/apache2/custom.d/bad-referrer-words.conf` 使用 nano、vim 或任何其他文本编辑器根据需要编辑 bad-referrer-words.conf 文件。 现在,在拉取任何未来的更新时,您的自定义恶意 Referrer 词库将不会被覆盖。 **下载用于自定义拦截 User-Agent 的自定义黑名单 User-Agent 包含文件** 允许您使用此新的包含文件添加您自己的自定义 User-Agent 列表。 - 将 blacklist-user-agents.conf 文件复制到该文件夹中 `sudo wget https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.4/custom.d/blacklist-user-agents.conf -O /etc/apache2/custom.d/blacklist-user-agents.conf` **注意:** 在 Apache Blocker 上,如果您想覆盖任何列入白名单的 Bot,可以将它们添加到此包含文件中,拦截器中之前列入白名单的 Bot 将被此包含文件覆盖。因此,假设出于某种“莫名其妙”的原因,您确实不希望 Googlebot 或 Bingbot 等任何搜索引擎访问或索引您的站点,您可以将它们添加到 blacklist-user-agents.conf 中,它们将被从拦截器中先前的白名单状态覆盖。这现在赋予用户对拦截器的完全控制权,而无需尝试修改 globalblacklist.conf 文件。因此,现在您可以自定义所有包含文件,并且仍然可以拉取 globalblacklist.conf 的每日更新,这不会触及您的任何自定义包含文件。 **包含 GLOBALBLACKLIST.CONF** 在目录块的开头,即在您的 Options 开启语句之后、其余主机配置之前,包含 globalblacklist.conf 文件,示例见下文。**删除 "<<<<<< This needs to be added" 部分** ``` ServerName local.dev ServerAlias www.local.dev DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined AllowOverride All Options FollowSymLinks Include custom.d/globalblacklist.conf # vim: syntax=apache ts=4 sw=4 sts=4 sr noet ``` 如果您在虚拟主机配置之后放置以下配置,则可以全局(针对所有虚拟主机)包含 globalblacklist.conf。 ``` # ###################################### # GLOBAL! deny bad bots and IP addresses # ###################################### # # should be set after s see https://httpd.apache.org/docs/2.4/sections.html#merging # AND-combine with preceding configuration sections AuthMerging And # include black list Include custom.d/globalblacklist.conf ``` **测试您的 APACHE 配置** 执行一次 Apache2 配置测试 `sudo apache2ctl configtest` 如果您没有收到错误,说明您遵循了我的说明,现在您可以通过简单的操作使拦截器生效。 `sudo service apache2 reload` 或者 `sudo service httpd reload` 拦截器现在处于活动和工作状态,因此您现在可以从另一台 Linux 机器运行一些简单的测试以确保其正常工作。 **测试** 从另一台 Linux 机器上的终端针对您自己的域名依次运行以下命令。 **将下面示例中的 yourdomain.com 替换为您的真实域名** `curl -A "googlebot" http://yourdomain.com` 应响应 200 OK `curl -A "80legs" http://yourdomain.com` `curl -A "masscan" http://yourdomain.com` 应响应 403 Forbidden `curl -I http://yourdomain.com -e http://100dollars-seo.com` `curl -I http://yourdomain.com -e http://zx6.ru` 应响应 403 Forbidden Apache Ultimate Bot Blocker 现在正在工作并保护您的网站!!! **更新 APACHE 恶意 BOT 拦截器** 现在得益于自动包含您自己的域名的功能,变得非常简单。 更新到最新版本现在非常简单: `sudo wget https://raw.githubusercontent.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/master/Apache_2.4/custom.d/globalblacklist.conf -O /etc/apache2/custom.d/globalblacklist.conf` `sudo apache2ctl configtest` `sudo service apache2 reload` 您将更新到最新版本,并且您的所有白名单域名都会自动包含在内。 # 使用 CRON 自动更新: 请参阅由 Luke Taylor @lutaylor 贡献的适用于 Apache 2.2 和 2.4 的最新自动更新 bash 脚本,地址: https://github.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/blob/master/update-apacheblocker.sh 现在放松一下,晚上睡个好觉,因为您知道您的站点正在告诉所有那些坏家伙“禁止访问”!!! # 为什么要拦截恶意 BOT ?

恶意 Bot 定义

##### 恶意 Bot 包括: - 恶意 Referrer - 恶意 User-Agent 字符串 - 垃圾 Referrer - 垃圾 Bot 和恶意 Bot - 麻烦或不受欢迎的 Bot - 与有利可图的 Malware、Adware 和 Ransomware Clickjacking 活动相关的站点 - 漏洞扫描器 - 赌博和色情网站 - 电子邮件采集器 - 内容抓取器 - 链接排名 Bot - 强力抓取内容的激进 Bot - 图片盗链站点和图片窃贼 - 与病毒或恶意软件相关的 Bot 或服务器 - 政府监控 Bot - 僵尸网络攻击网络 (Mirai) - 已知的 Wordpress 主题检测器(定期更新) - 您的竞争对手用来试图提升其 SEO 的 SEO 公司 - 链接研究和反向链接测试工具 - 阻止 Google Analytics “幽灵”垃圾信息 - 浏览器 Adware 和 Malware(例如 Yontoo) ### 贡献您发现的恶意 referer 请将它们添加到 https://github.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/blob/master/Pull%20Requests%20Here%20Please/badreferers.list 文件中,然后发送一个 Pull Request (PR)。 所有添加的内容将在合并前经过准确性检查。 ### 问题: 在问题系统中记录任何关于错误列表的问题,我们将进行调查 并在必要时将其移除。 ### 没有 Apache 服务器的 Root 权限且无法运行此拦截器? 2.2017.03 版本为那些无法运行完整 Apache 恶意 Bot 拦截器的用户引入了 .htaccess 版本的垃圾 Referrer 拦截器,请查看此仓库中的 https://github.com/mitchellkrogza/apache-ultimate-bad-bot-blocker/tree/master/_htaccess_versions 文件夹以获取说明。 ## 帮助支持本项目 [Buy me Coffee](https://ko-fi.com/mitchellkrog) Bot 试图通过伪装其 User-Agent 使自己看起来像其他软件或网站。 它们的 User-Agent 名称可能看起来无害,甚至完全合法。 例如,“^Java”,但根据 Project Honeypot 的说法,它实际上是最危险的之一,但是很多 合法 Bot 的 User-Agent 字符串中包含“Java”,因此许多人采取的拦截方法不仅 无知,而且拦截了一些非常合法的爬虫,包括 Google 和 Bing 的一些爬虫。 # 欢迎使用 Apache Web Server 2.4.x 终极恶意 Bot 和 Referer 拦截器 ### 我的疯狂方法论 此 Bot 拦截器列表旨在作为 Apache 包含文件使用,并使用 Apache BrowserMatchNoCase 指令。这样 .conf 文件可以由 Apache 一次性加载到内存中,并可供您运营的所有网站使用。 您只需使用一个 Include 语句(示例如下) 我个人发现 BrowserMatchNoCase 指令比使用 SetEnvIfNoCase User-Agent 更准确,因为 BrowserMatchNoCase 不区分大小写,且 根据我的测试,它比 SetEnvIfNoCase 更准确。 我的方法还产生了一个更易于维护的文件,不需要复杂的正则表达式, 只需 Bot 的名称。BrowserMatchNoCase 会完成其余工作。您可以使用正则表达式, 如果愿意,但这不是必需的,我通过使用 Chrome 扩展 User-Agent Switcher for Chrome 进行测试证明了这一点。 - 无需使用“^Aboundex”即可找到 User-Agent“Aboundex”……对于任何人来说,比其他使用正则表达式的列表 更易于维护。 - 同样,不需要使用“Download\ Demon”,您现在只需使用 “Download Demon”。 - 此外,如果我们有一个规则,如下所示的“Image Stripper”,而一个 Bot 决定将其 User-Agent 字符串更改为“NOT Image Stripper I Promise”,它无论如何都会被捕获 并立即被拦截。 我将 Bot 名称大写只是为了便于阅读和维护,请记住它 不区分大小写,因此会捕获任何组合,如“Bot”、“bOt”和“bOT”。 因此,对于那些对正则表达式一窍不通的人来说,我的 Apache 恶意 Bot 拦截器是您的救星!!! ### 它是集中式的: 其美妙之处在于它是所有网站使用的一个中心文件。 这意味着只有一个地方可以进行修改,即在您的 日志文件中发现的新 Bot。在简单的“sudo service apache2 reload”之后, 任何更改都会立即应用于所有站点。 ### 它短小精悍 文件大小很小。在撰写本文时以及首次公开提交时, 包括所有“Apache 忽略”的注释在内的文件大小仅为 212 kb。 它是如此轻量级,以至于 Apache 甚至感觉不到它的存在。它已经包含了数千个条目。 ### 没有复杂的重写规则: 这也不使用会给 Apache 带来开销的 Rewrite Rules 和 Conditions,它发送一个简单的 403 Forbidden 响应,搞定!!! ### APACHE 会因此而爱死您!!!! 与许多人选择的常规 .htaccess 方法相比,这种方法对 Apache 来说非常轻量级。 .htaccess 方法有点笨拙,因为每个站点 都必须拥有自己的 .htaccess,而且每次有人请求您的网站时,.htaccess 都会被 访问并必须进行检查,这对 Apache 来说是不必要的开销,更不用说 在维护和更新规则集时的痛苦了。 .htaccess 简直糟透了。我在 9 年后迁移到 Nginx 的一个原因,但我将继续保持此文件更新,因为它稳固且有效。 ## APACHE 终极恶意 BOT 拦截器的功能: - 广泛的恶意和已知恶意 Bot 及抓取器列表(几乎每天更新) - 拦截垃圾 Referrer 域名和网站 - 拦截 Semalt.com、Builtwith.com、WooRank.com 等许多其他 SEO 数据收集公司(定期更新) - 拦截与 Adware、Malware 和 Ransomware 相关的 Clickjacking 站点 - 拦截通过利用您的域名和网站投放广告赚取不义之财的色情和赌博网站 - 拦截您甚至在 Nginx 日志中都看不到的恶意域名和 IP。多亏了我所有 SSL 站点上的内容安全策略 (CSP),我可以在事物到达 Nginx 并被 CSP 拦截之前,看到它们试图从我的站点拉取资源。 - Anti DDOS 过滤器和针对激进 Bot 的速率限制 - 按字母顺序排列以便于维护(欢迎 Pull Requests) - 某些重要 Bot 的注释部分,以便在拦截前确定 - 包含已知忽略 robots.txt 规则并在互联网上到处窥探的 Cyveillance IP 段 - 将 Google、Bing 和 Cloudflare IP 段列入白名单 - 将您自己的 IP 段列入白名单,以免误拦截。 - 能够添加您希望拦截的其他 IP 段和 IP 块。 - 如果存在恶意的东西,它已经在这里并被拦截了!! ### 支持PUNYCODE / IDN 域名 许多列表将奇怪的域名放入其 hosts 文件中。您的 hosts 文件和 DNS 将无法理解这一点。此列表使用转换后的域名,这些域名采用正确的 DNS 格式,可以被任何操作系统理解。**避免使用**那些未在其列表中放入正确格式化域名结构的列表。 例如 域名: `lifehacĸer.com`(注意 K) 实际上转换为: `xn--lifehacer-1rb.com` 您可以在任何操作系统上执行 nslookup,它将正确解析。 `nslookup xn--lifehacer-1rb.com` - 请参阅:https://www.charset.org/punycode 了解更多信息。 ## 警告: 在使用之前,请了解您为什么要使用 Apache 恶意 Bot 拦截器。 请不要在不了解其作用的情况下简单地复制和粘贴。 不要成为复制粘贴的 Linux“大师”,在使用之前正确学习, 并始终一步一步测试您所做的一切。 ## 监控您的操作: 实施此功能后,请务必监控您的网站日志。我建议您首先 将其加载到一个站点中,并在将其投入生产到所有网站之前监控是否存在任何可能的误报。 还要每天监控您的日志,查找您希望 拦截的新的恶意 referer 和 User-Agent 字符串。您添加到此列表的最佳来源是您自己的服务器日志,而不是我的。 ## 如何每日监控您的 APACHE 日志(简单方法): 非常感谢 https://blog.nexcess.net/2011/01/21/one-liners-for-apache-log-files/ 要每日监控网站日志文件的顶级 referer,请使用以下简单的 cron 作业,它将在每天早上通过电子邮件向您发送来自特定网站日志 文件的顶级 referer/User-Agent 列表。这只是一个站点的一个 cron 作业示例。为您想要监控的每个站点设置多个作业。这是一个每天早上 8 点运行的 cron,并通过电子邮件将精简版的 referer 日志发送给我。当我说精简时,是指站点的域名以及 Google 和 Bing 等其他 referer 已从结果中剔除。当然,您必须在 下面的示例中更改日志文件名、域名和您的电子邮件地址。用于收集 User-Agent 的第二个 cron 不会剔除任何 referer,但如果您愿意,可以从第一个示例中复制 awk 语句 !~ 来添加该功能。 ##### 用于监控 Apache 每日 Referer 的 Cron `00 08 * * * tail -10000 /var/log/apache/mydomain-access.log | awk '$11 !~ /google|bing|yahoo|yandex|mywebsite.com/' | awk '{print $11}' | tr -d '"' | sort | uniq -c | sort -rn | head -1000 | mail -s "Top 1000 Referers for Mydomain.com" me@mydomain.com` ##### 用于监控 Apache 每日 User-Agent 的 Cron `00 08 * * * tail -50000 /var/log/apache/mydomain-access.log | awk '{print $12}' | tr -d '"' | sort | uniq -c | sort -rn | head -1000 | mail -s "Top 1000 Agents for Mydomain.com" me@mydomain.com` # 阻止 GOOGLE ANALYTICS “幽灵”垃圾信息的简单配置说明 仅使用 Apache 拦截器并不能阻止 Google Analytics 幽灵 Referrer 垃圾信息,因为它们直接攻击 Analytics,并不一定总是访问您的网站。 您应该在 Analytics 中使用正则表达式过滤器来防止幽灵 Referrer 垃圾信息。 为此,我们为您创建了几个 google-exclude-0*.txt 文件,它们会在 Nginx Blocker 更新的同时更新。随着列表的增长,将创建更多的排除文件。 ## 在 Analytics 上阻止幽灵垃圾信息 请按照下面的分步可视说明将这些 google-exclude 文件作为细分添加到您的网站。
Google Analytics - Adding Segments to Stop Ghost Spam
Google Analytics - Adding Segments to Stop Ghost Spam
Google Analytics - Adding Segments to Stop Ghost Spam
Google Analytics - Adding Segments to Stop Ghost Spam
Google Analytics - Adding Segments to Stop Ghost Spam
Google Analytics - Adding Segments to Stop Ghost Spam
Google Analytics - Adding Segments to Stop Ghost Spam
## 使用 Google Webmaster Tools 拦截垃圾 Referrer 域名(如何使用 google-disavow.txt 文件) 我添加了一个名为 google-disavow.txt 的 Google Disavow 文本文件的创建。此文件可在 Google 的 Webmaster Tools 中使用,以将所有这些域名作为垃圾或恶意链接拦截。请谨慎使用。 ## 使用 Fail2Ban 在防火墙级别拦截激进 Bot 我添加了我编写的自定义 Fail2Ban 过滤器和操作,用于监控您的 Apache 日志中生成大量 403 错误的 Bot。此针对 Fail2Ban 的自定义 jail 将扫描 1 周内的日志,并将违规者封禁 24 小时。 这对于阻止一些重复违规者并防止他们用 403 错误填满您的日志文件有很大帮助。 请参阅 Fail2Ban 文件夹以获取配置此 Apache 恶意 Bot 拦截器出色附加组件的说明。 ## 帮助支持本项目 [Buy me Coffee](https://ko-fi.com/mitchellkrog) ### 另请查看被黑恶意软件网站大列表 此仓库包含我遇到的所有被恶意软件感染的黑客网站列表。 大多数站点所有者不知道他们的站点已被黑客入侵并正被用于植入恶意软件。 在这里查看:https://github.com/mitchellkrogza/The-Big-List-of-Hacked-Malware-Web-Sites ### 其他一些免费项目 - https://github.com/mitchellkrogza/nginx-ultimate-bad-bot-blocker - https://github.com/mitchellkrogza/apache-ultimate-bad-bot-blocker - https://github.com/mitchellkrogza/Badd-Boyz-Hosts - https://github.com/mitchellkrogza/Ultimate.Hosts.Blacklist - https://github.com/mitchellkrogza/Stop.Google.Analytics.Ghost.Spam.HOWTO - https://github.com/mitchellkrogza/The-Big-List-of-Hacked-Malware-Web-Sites - https://github.com/mitchellkrogza/fail2ban-useful-scripts - https://github.com/mitchellkrogza/linux-server-administration-scripts - https://github.com/mitchellkrogza/Travis-CI-Nginx-for-Testing-Nginx-Configuration - https://github.com/mitchellkrogza/Travis-CI-for-Apache-For-Testing-Apache-and-PHP-Configurations - https://github.com/mitchellkrogza/Fail2Ban-Blacklist-JAIL-for-Repeat-Offenders-with-Perma-Extended-Banning - https://github.com/funilrys/PyFunceble - https://github.com/funilrys/dead-hosts - https://github.com/mitchellkrogza/The-Big-List-of-Hacked-Malware-Web-Sites - https://github.com/mitchellkrogza/Suspicious.Snooping.Sniffing.Hacking.IP.Addresses - https://github.com/mitchellkrogza/Fail2Ban.WebExploits ### 致谢与贡献者: 此项目背后的生成器脚本和代码的许多部分已从多个来源改编。实际上很难提到每个人,但这里有一些关键人物,他们的代码小片段帮助我一直引入新功能。给他们一些支持,也看看他们的一些项目 - Luke Taylor @lutaylor(改进了安装和更新脚本,并修复了 Apache 2.2、2.4 和 CentOS 版本的路径) - Konstantin Goretzki @konstantingoretzki https://github.com/konstantingoretzki(改进了 Fail2Ban 过滤器上的正则表达式) - Stevie-Ray Hartog https://github.com/Stevie-Ray - Nissar Chababy @funilrys - https://github.com/funilrys/funceble(用于检查 ACTIVE、INACTIVE 和 EXPIRED 域名的优秀脚本) - Marius Voila https://github.com/mariusv - Cătălin Mariș https://github.com/alrra - deformhead https://github.com/deformhead - bluedragonz https://github.com/bluedragonz - Alexander https://github.com/shoonois - Steven Black https://github.com/StevenBlack - Fail2Ban - https://github.com/fail2ban - Sir Athos from StackOverFlow - http://stackoverflow.com/users/2245910/sir-athos(帮助进行 Travis Build 标记和提交) - StackOverflow - http://stackoverflow.com/(来自数百个问答的 bash 脚本) - SuperUser - http://superuser.com/(来自各种问答的片段) 如果您认为您的名字应该在这里,请给我留言。 ### 对摄影感兴趣? 来 [mitchellkrog.com](https://mitchellkrog.com) 或 [Facebook](https://www.facebook.com/MitchellKrogPhotography) 逛逛看我,或者在 Twitter 上关注我 Follow @MitchellKrog ## 帮助支持本项目 [Buy me Coffee](https://ko-fi.com/mitchellkrog) ## 更新通知系统 请将您的电子邮件地址订阅到 **https://groups.google.com/forum/#!forum/apache-ultimate-bad-bot-blocker** 的邮件列表 或直接发送一封空白电子邮件至 **apache-ultimate-bad-bot-blocker+subscribe@googlegroups.com** 进行订阅。 **请确保您已订阅通知**,以便在拦截器更新时以及发生任何重要或关键任务变更时收到通知。 ## 同时在 twitter 上关注我 Follow @ubuntu101za # MIT License ## Copyright (c) 2017 Mitchell Krog - mitchellkrog@gmail.com ## https://github.com/mitchellkrogza Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
标签:Apache, Apache 2.4, AppImage, Bad Bot拦截, DDoS防护, Fail2Ban, IP黑名单, SEO垃圾流量, User-Agent过滤, WAF, Web应用防火墙, Web服务器安全, WordPress安全, 勒索软件防护, 反爬虫, 垃圾引用屏蔽, 域名收集, 客户端加密, 密码管理, 广告软件拦截, 应用安全, 恶意爬虫, 恶意软件拦截, 操作系统监控, 流量清洗, 漏洞扫描防护, 点击劫持防护, 网络安全, 重定向拦截, 隐私保护