<img src=" alt="Apache Ultimate Bad Bot, User-Agent and Spam Referrer Blocker - Apache Block Bad Bots, User-Agents, 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"/>
| REPO | BECOME A SPONSOR |
| :--: | :--: |
| ![DUB]() | Your logo and link to your domain will appear here if you become a sponsor. Simply email me on if you would like to sponsor this project as South Africa is not supported yet under the Github sponsor program. |
<a href=' src=' alt='Follow '></a> | Help Support Me at |
_______________
#### : V3.2026.10.2743
#### Bad Referrer Count: 7115
#### Bad Bot Count: 699
#### Fake Googlebots: 218
____________________
:exclamation:There are now two distinctly different of this blocker.:exclamation:
<a href=" 2.2 > 2.4+ (access_compat)</a> [ TESTED ON APACHE 2.2 > 2.4.27 ]
<a href=" 2.4+ ONLY</a> [ TESTED ON APACHE 2.4 > 2.4.34 ]
Please make sure you are subscribed to Github Notifications to be notified when the blocker is updated or when any important or mission critical (potentially breaking) changes may take place.
##### Also follow me on twitter
<a href=' src=' alt='Follow '></a>
<img src=" alt="Buy me Coffee" width="300"/>
<img src=" alt="Apache Bad Bot Blocker"/>
<img src="
COPY THE GLOBALBLACKLIST.CONF FILE FROM THE REPO
$APACHE_CONF is generally located at /etc/apache2 or /etc/httpd depending on OS
Copy the contents of globalblacklist.conf into your $APACHE_CONF/custom.d folder.
e.g. /etc/apache2/custom.d on Ubuntu/Debian
/etc/httpd on RHEL/centos
You need to create this folder.
The following directions use /etc/apache2 as an example.
sudo mkdir /etc/apache2/custom.d
sudo wget -O /etc/apache2/custom.d/globalblacklist.conf
If your Linux distribution does not have wget you can replace the wget commands using curl as follows:
curl -sL -o /etc/apache2/custom.d/globalblacklist.conf
<img src="
WHITELIST ALL YOUR OWN DOMAIN NAMES AND IP ADDRESSES
Whitelist all your own domain names and IP addresses. Please note important changes, this is now done using include files so that you do not have to keep reinserting your whitelisted domains and IP addresses every time you update.
:exclamation: :exclamation: :exclamation: WARNING: Please do NOT ever use 127.0.0.1 as a whitelisted IP address in whitelist-ips.conf it will cause the blocker to stop functioning.
sudo wget -O /etc/apache2/custom.d/whitelist-ips.conf
sudo wget -O /etc/apache2/custom.d/whitelist-domains.conf
Use nano, vim or any other text editor to edit both whitelist-ips.conf and whitelist-domains.conf to include all your own domain names and IP addresses that you want to specifically whitelist from the blocker script.
When pulling any future updates now you can simply pull the latest globalblacklist.conf file and it will automatically include your whitelisted domains and IP addresses. No more remembering having to do this yourself.
<img src="
DOWNLOAD CUSTOM BLACKLIST INCLUDE FILE FOR IP ADDRESS AND IP RANGE BLOCKING
Blacklist any IP addresses or Ranges you wish to keep out of your servers. Please note important changes, this is now done using include files so that you have full control over what IP addresses and IP Ranges and blocked from your Apache Server.
sudo wget -O /etc/apache2/custom.d/blacklist-ips.conf
Use nano, vim or any other text editor to edit the blacklist-ips.conf file as you like.
When pulling any future updates now your custom IP blacklist will not be o.
<img src="
DOWNLOAD CUSTOM BAD REFERRER WORDS INCLUDE FILE FOR CUSTOMIZED SCANNING OF BAD WORDS
Scan for any bad referrer words you wish to keep out of your servers. Please note important changes, this is now done using include files so that you have full control over what IP addresses and IP Ranges and blocked from your Apache Server.
sudo wget -O /etc/apache2/custom.d/bad-referrer-words.conf
Use nano, vim or any other text editor to edit the bad-referrer-words.conf file as you like.
When pulling any future updates now your custom bad referrer words list will not be o.
<img src="
DOWNLOAD CUSTOM BLACKLIST USER-AGENTS INCLUDE FILE FOR CUSTOMIZED BLOCKING OF USER AGENTS
Allows you to add your own custom list of user agents with this new include file.
sudo wget -O /etc/apache2/custom.d/blacklist-user-agents.conf
NOTE: On the Apache Blocker if you want to o any of the whitelisted bots you can add them to this include file and the pre whitelisted bots in the blocker will be o by this include file. So let's say for some "obscure" reason you really do not want any search engines like Googlebot or Bingbot to e or index your site, you add them to your blacklist-user-agents.conf and they will be o from the earlier whitelisting in the blocker. This now gi total control over the blocker without every having to try and modify the globalblacklist.conf file. So now you can customize all your include files and you can still pull the daily updates of globalblacklist.conf and it will not touch any of your custom include files.
<img src="
INCLUDE THE GLOBALBLACKLIST.CONF
Include the globalblacklist.conf file in the beginning of a directory block just after your opening Options statements and before the rest of your host config example below. Remove the "<<<<<< This needs to be added" part
You can include globalblacklist.conf globally (for all hosts) if you put the following configuration after host configuration.
<img src="
TEST YOUR APACHE CONFIGURATION
Do an Apache2 Config Test
sudo apache2ctl configtest
If you get no errors then you followed my instructions so now you can make the blocker go live with a simple.
sudo service apache2 reload
or
sudo service httpd reload
The blocker is now active and working so now you can run some simple tests from another linux machine to make sure it's working.
<img src="
*TESTING**
Run the following commands one by one from a terminal on another linux machine against your own domain name.
substitute yourdomain.com in the examples below with your REAL domain name
curl -A "googlebot"
Should respond with 200 OK
curl -A "80legs"
curl -A "masscan"
Should respond with 403 Forbidden
curl -I -e
curl -I -e
Should respond with 403 Forbidden
The Apache Ultimate Bot Blocker is now WORKING and PROTECTING your web sites !!!
<img src="
UPDATING THE APACHE BAD BOT BLOCKER is now easy thanks to the automatic includes for whitelisting your own domain names.
Updating to the latest is now as simple as:
sudo wget -O /etc/apache2/custom.d/globalblacklist.conf
sudo apache2ctl configtest
sudo service apache2 reload
And you will be up to date with all your whitelisted domains included automatically for you now.
See the latest auto updater bash script for Apache 2.2 and 2.4 contributed by Luke Taylor at:
Relax now and sleep better at night knowing your site is telling all those baddies FORBIDDEN !!!
<img src=" alt="Apache 2.4 Bad Bot Blocker"/>
<img src="
COPY THE GLOBALBLACKLIST.CONF FILE FROM THE REPO
$APACHE_CONF is generally located at /etc/apache2 or /etc/httpd depending on OS
Copy the contents of globalblacklist.conf into your $APACHE_CONF/custom.d folder.
e.g. /etc/apache2/custom.d on Ubuntu/Debian
/etc/httpd on RHEL/centos
You need to create this folder.
The following directions use /etc/apache2 as an example.
sudo mkdir /etc/apache2/custom.d
sudo wget -O /etc/apache2/custom.d/globalblacklist.conf
If your Linux distribution does not have wget you can replace the wget commands using curl as follows:
curl -sL -o /etc/apache2/custom.d/globalblacklist.conf
<img src="
WHITELIST ALL YOUR OWN DOMAIN NAMES AND IP ADDRESSES
Whitelist all your own domain names and IP addresses. Please note important changes, this is now done using include files so that you do not have to keep reinserting your whitelisted domains and IP addresses every time you update.
:exclamation: :exclamation: :exclamation: WARNING: Please do NOT ever use 127.0.0.1 as a whitelisted IP address in whitelist-ips.conf it will cause the blocker to stop functioning.
sudo wget -O /etc/apache2/custom.d/whitelist-ips.conf
sudo wget -O /etc/apache2/custom.d/whitelist-domains.conf
Use nano, vim or any other text editor to edit both whitelist-ips.conf and whitelist-domains.conf to include all your own domain names and IP addresses that you want to specifically whitelist from the blocker script.
When pulling any future updates now you can simply pull the latest globalblacklist.conf file and it will automatically include your whitelisted domains and IP addresses. No more remembering having to do this yourself.
<img src="
DOWNLOAD CUSTOM BLACKLIST INCLUDE FILE FOR IP ADDRESS AND IP RANGE BLOCKING
Blacklist any IP addresses or Ranges you wish to keep out of your servers. Please note important changes, this is now done using include files so that you have full control over what IP addresses and IP Ranges and blocked from your Apache Server.
sudo wget -O /etc/apache2/custom.d/blacklist-ips.conf
Use nano, vim or any other text editor to edit the blacklist-ips.conf file as you like.
When pulling any future updates now your custom IP blacklist will not be o.
<img src="
DOWNLOAD CUSTOM BAD REFERRER WORDS INCLUDE FILE FOR CUSTOMIZED SCANNING OF BAD WORDS
Scan for any bad referrer words you wish to keep out of your servers. Please note important changes, this is now done using include files so that you have full control over what IP addresses and IP Ranges and blocked from your Apache Server.
sudo wget -O /etc/apache2/custom.d/bad-referrer-words.conf
Use nano, vim or any other text editor to edit the bad-referrer-words.conf file as you like.
When pulling any future updates now your custom bad referrer words list will not be o.
<img src="
DOWNLOAD CUSTOM BLACKLIST USER-AGENTS INCLUDE FILE FOR CUSTOMIZED BLOCKING OF USER AGENTS
Allows you to add your own custom list of user agents with this new include file.
sudo wget -O /etc/apache2/custom.d/blacklist-user-agents.conf
NOTE: On the Apache Blocker if you want to o any of the whitelisted bots you can add them to this include file and the pre whitelisted bots in the blocker will be o by this include file. So let's say for some "obscure" reason you really do not want any search engines like Googlebot or Bingbot to e or index your site, you add them to your blacklist-user-agents.conf and they will be o from the earlier whitelisting in the blocker. This now gi total control over the blocker without every having to try and modify the globalblacklist.conf file. So now you can customize all your include files and you can still pull the daily updates of globalblacklist.conf and it will not touch any of your custom include files.
<img src="
INCLUDE THE GLOBALBLACKLIST.CONF
Include the globalblacklist.conf file in the beginning of a directory block just after your opening Options statements and before the rest of your host config example below. Remove the "<<<<<< This needs to be added" part
You can include globalblacklist.conf globally (for all hosts) if you put the following configuration after host configuration.
<img src="
TEST YOUR APACHE CONFIGURATION
Do an Apache2 Config Test
sudo apache2ctl configtest
If you get no errors then you followed my instructions so now you can make the blocker go live with a simple.
sudo service apache2 reload
or
sudo service httpd reload
The blocker is now active and working so now you can run some simple tests from another linux machine to make sure it's working.
<img src="
*TESTING**
Run the following commands one by one from a terminal on another linux machine against your own domain name.
substitute yourdomain.com in the examples below with your REAL domain name
curl -A "googlebot"
Should respond with 200 OK
curl -A "80legs"
curl -A "masscan"
Should respond with 403 Forbidden
curl -I -e
curl -I -e
Should respond with 403 Forbidden
The Apache Ultimate Bot Blocker is now WORKING and PROTECTING your web sites !!!
<img src="
UPDATING THE APACHE BAD BOT BLOCKER is now easy thanks to the automatic includes for whitelisting your own domain names.
Updating to the latest is now as simple as:
sudo wget -O /etc/apache2/custom.d/globalblacklist.conf
sudo apache2ctl configtest
sudo service apache2 reload
And you will be up to date with all your whitelisted domains included automatically for you now.
See the latest auto updater bash script for Apache 2.2 and 2.4 contributed by Luke Taylor at:
Relax now and sleep better at night knowing your site is telling all those baddies FORBIDDEN !!!
<h4 id="define-bad-bots">
Definition of Bad Bots
</h4>
##### Bad bots are:
please add them into the
file and then send a Pull Request (PR).
All additions will be checked for accuracy before being merged.
Log any issues regarding incorrect listings on the issues system and they will be in
and removed if necessary.
2.2017.03 introduced .htaccess of the spam referrer for those unable to run the full Apache Bad Bot Blocker look inside the folder in this repo for instructions.
<img src=" alt="Buy me Coffee" width="300"/>
Bots attempt to make themselves look like other software or web sites by disguising their user agent.
Their user agent names may look harmless, perfectly legitimate even.
For example, "^Java" but according to Project Honeypot, it's actually one of the most dangerous BUT a lot of
legitimate bots out there have "Java" in their user agent string so the approach taken by many to block is
not only ignorant but also blocking out very legitimate crawlers including some of Google's and Bing's.
This bot blocker list is designed to be an Apache include file and uses the apache
BrowserMatchNoCase directive. This way the .conf file can be loaded
once into memory by Apache and be a to all web sites that you operate.
You simply need to use an Include statement (example below)
I personally find the BrowserMatchNoCase Directive to be more accurate than using
SetEn User-Agent because BrowserMatchNoCase is not case sensitive and
from my tests is more accurate that SetEn.
My method also results in a cleaner file to maintain that requires no complex regex
other than the Name of the Bot. BrowserMatchNoCase will do the rest. You can use Regex
if you like but it's NOT needed and I proved it by testing with the Chrome extension
User-Agent Switcher for Chrome.
I only capitalise bot names in my list for ease of reading and maintenance, remember its
not case-sensitive so will catch any combination like "Bot" "bOt" and "bOT".
So for those of you who SUCK with Regex my Apache Bad Bot Blocker is your saviour !!!
The beauty of this is that it is one central file used by all your web sites.
This means there is only place to make amendments ie. adding new bots that you
discover in your log files. Any changes are applied immediately to all sites after
a simple "sudo service apache2 reload".
The file is tiny in size. At the time of this writing and the first public commit of this
the file size including all the commenting "which Apache ignores" is a mere 212 kb in size.
It is so lightweight that Apache does not even know it's there. It already contains thousands
of entries.
This also does not use ReWrite Rules and Conditions which also put o onto
Apache, this sends a simple 403 Forbidden Response and DONE !!!
This approach also makes this very lightweight on Apache the usual .htaccess
approach that many choose. The .htaccess approach is a little clumsy because every site
has to have its own one and every time someone requests your web site the .htaccess gets
hit and has to be checked, this is unnecessary o for Apache and not to mention
a pain when it comes to maintenance and updating your ruleset.
.htaccess just sucks full stop. One reason after 9 years I ha e to
Nginx but will continue to keep this file updated as it is solid and it works.
For instance
The domain:
lifehacĸer.com (note the K)
actually translates to:
xn--lifehacer-1rb.com
You can do an nslookup on any operating system and it will resol.
nslookup xn--lifehacer-1rb.com
Please understand why you are using the Apache Bad Bot Blocker before you even use this.
Please do not simply copy and paste without understanding what this is doing.
Do not become a copy and paste Linux "Guru", learn things properly before you use them
and always test e you do one step at a time.
MAKE SURE to monitor your web site logs after implementing this. I suggest you first
load this into one site and monitor it for any possible false positi putting
this into production on all your web sites.
Also monitor your logs daily for new bad referers and user-agent strings that you
want to block. Your best source of adding to this list is your own server logs, not mine.
With great thanks and appreciation to
To monitor your top referer's for a web site's log file's on a daily basis use the following simple
cron jobs which will email you a list of top referer's / user agents every morning from a particular web site's log
files. This is an example for just one cron job for one site. Set up multiple one's for each one you
want to monitor. Here is a cron that runs at 8am every morning and emails me the stripped down log of
referers. When I say stripped down, the domain of the site and other referers like Google and Bing are
stripped from the results. Of course you must change the log file name, domain name and your email address in
the examples below. The second cron for collecting User agents does not do any stripping out of any referers but you
can add that functionality if you like copying the awk statement !~ from the first example.
##### Cron for Monitoring Daily Referers on Apache
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"
##### Cron for Monitoring Daily User Agents on Apache
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"
Simply using the Apache blocker does not stop Google Analytics ghost referral spam because they are hitting Analytics directly and not always necessarily touching your website.
You should use regex filters in Analytics to prevent ghost referral spam.
For this there are several google-exclude-0*.txt files which have been created for you and they are updated at the same time when the Nginx Blocker is updated. As the list grows there will be more exclude files created.
Follow the step by step instructions below to add these google-exclude files as segments to your web site.
<table style="width:100%;margin:0;">
<tr>
<td align="left"><img src=" alt="Google Analytics - Adding Segments to Stop Ghost Spam"/></td>
</tr>
<tr>
<td align="left"><img src=" alt="Google Analytics - Adding Segments to Stop Ghost Spam"/></td>
</tr>
<tr>
<td align="left"><img src=" alt="Google Analytics - Adding Segments to Stop Ghost Spam"/></td>
</tr>
<tr>
<td align="left"><img src=" alt="Google Analytics - Adding Segments to Stop Ghost Spam"/></td>
</tr>
<tr>
<td align="left"><img src=" alt="Google Analytics - Adding Segments to Stop Ghost Spam"/></td>
</tr>
<tr>
<td align="left"><img src=" alt="Google Analytics - Adding Segments to Stop Ghost Spam"/></td>
</tr>
<tr>
<td align="left"><img src=" alt="Google Analytics - Adding Segments to Stop Ghost Spam"/></td>
</tr>
</table>
I ha the creation of a Google Disavow text file called google-disavow.txt. This file can be used in Google's Webmaster Tools to block all these domains out as spammy or bad links. Use with caution.
I ha a custom Fail2Ban filter and action that I ha which monitors your Apache logs for bots that generate
a large number of 403 errors. This custom jail for Fail2Ban will scan logs over a 1 week period and ban the offender for 24 hours.
It helps a great deal in keeping out some repeat offenders and pre them from filling up your log files with 403 errors.
See the Fail2Ban folder for instructions on configuring this great add on for the Apache Bad Bot Blocker.
<img src=" alt="Buy me Coffee" width="300"/>
This repository contains a list of all web sites I come across that are hacked with malware.
Most site owners are unaware their sites have been hacked and are being used to plant malware.
Check it out at:
Many parts of the generator scripts and code running behind this project have been adapted from multiple sources. In fact it's so hard to mention e but here are a few key people whose little snippets of code ha me introduce new features all the time. Show them some love and check out some of their projects too
If you believe your name should be here, drop me a line.
Come drop by and visit me at mitchellkrog.com or Facebook or Follow Me on Twitter <a href=' src=' alt='Follow '></a>
<img src=" alt="Buy me Coffee" width="300"/>
<img src="
Please subscribe your email address to the mailing list at
or simply send a blank email to to subscribe.
Please make sure you are subscribed to notifications to be notified when the blocker is updated and also to be notified when any important or mission critical changes take place.
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 abo 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.
开发语言:C
Star 数:984
该项目属于安全软件方向的开源资源,代码结构清晰,适合安全研究人员学习参考。项目围绕Apache Block Bad Bots, (Referer) Spam Referrer Blocker, Vulnerability Scanners, Malware, Adware, Ransomware, Malicious Sites, Wordpress Theme Detectors and Fail2Ban Jail for Repeat Offenders展开,提供了可运行的实现,对理解相关安全机制、工具原理与攻防技术具有较高的研究价值。
从技术实现角度看,此类项目的核心在于对底层原理的深入理解与工程化落地。开发者在研究过程中可以结合官方文档与社区讨论,梳理项目的初始化流程、核心模块职责与数据流转,逐步掌握其中的技术细节与设计思路。
1. 下载源码压缩包,解压到本地环境。
2. 根据项目类型准备对应的运行环境与依赖。
3. 按照 README 中的步骤完成配置与部署。
4. 在隔离的测试环境中运行验证,避免影响生产系统。
本资源来源于开源社区,仅供安全研究、技术学习与合法授权范围内的攻防演练使用,请勿用于任何非法或侵害他人权益的用途。使用本项目产生的一切后果由使用者自行承担。
| 资源标题 | apache-ultimate-bad-bot-blocker - Apache Block Bad Bots, (Referer) Spam Referrer Blo |
| 所属分类 | 安全软件 |
| 发布作者 | admin |
| 发布时间 | 2026-10-05 22:34:39 |
| 下载权限 | 免费下载 |
| 附件数量 | 2 个下载链接 |
| 浏览次数 | 231 |
| 讨论数量 | 0 |
| 主题状态 | 正常讨论中 |