Recently, I’ve encountered some very aggressive WordPress spam bots. These bots post a new spam comment almost every minute for hours on end. Needless to say my spam queue is a mess. I wrote the following plugin to solve this problem.
What is Spam Log?
Spam Log is a simple WordPress plugin that logs a message every time a comment is marked as spam. Each log message includes the IP address of the poster and the comment’s ID. The log can easily be processed by fail2ban. fail2ban is a daemon that scans log files for misbehaving clients and bans them by IP address. Here is sample output generated by Spam Log:
2009-04-20 04:15:03 comment id=527 from host=83.233.30.32 marked as spam 2009-04-20 04:18:15 comment id=528 from host=83.233.30.32 marked as spam 2009-04-20 04:20:36 comment id=529 from host=83.233.30.32 marked as spam 2009-04-20 04:21:46 comment id=530 from host=83.233.30.32 marked as spam 2009-04-20 04:22:49 comment id=531 from host=83.233.30.32 marked as spam
Why use Spam Log and fail2ban if Akismet/wp-recaptcha/etc. is already catching all the spam?
- Many spammers post 50+ comments a day from a single IP address. Even if every comment is correctly marked as spam, the volume alone means that you can’t easily monitor the spam queue for false positives. Spam Log and fail2ban should considerably reduce the total amount of spam.
- Even if spam comments never appear on your blog, they still waste valuable resources on your server. Low-memory virtual servers need all available resources for serving legitimate users. Banning spammers at the firewall before they ever connect to your web server is very efficient.
Installation
Spam Log
- Upload the
spam-logfolder to thewp-content/pluginsdirectory. - Active the plugin through the WordPress Admin menu.
- Set the location of the spam log through Spam Log’s Options page in the WordPress Admin menu. By default, the location is set to
wp-content/spam.log. The file or containing directory needs to be writeable by the user that the web server runs as. On Debian or Ubuntu systems, you can do the following:
$ sudo touch /path/to/spam.log
$ sudo chown www-data.www-data /path/to/spam.log
fail2ban Configuration
Create /etc/fail2ban/filter.d/spam-log.conf with the following contents:
[Definition] failregex = ^\s*comment id=\d+ from host=<HOST> marked as spam$ ignoreregex =
Add the following lines to /etc/fail2ban/jail.local:
[spam-log] enabled = true port = http,https filter = spam-log logpath = /path/to/spam.log maxretry = 5 findtime = 3600 bantime = 86400
Change logpath to the path you set on Spam Log’s Options page. This configuration will ban an IP address for a day if it’s used to post 5 comments within an hour that are marked as spam. Warning: Some captcha plugins mark comments as spam when a user fails a captcha. Be careful decreasing maxretry if you’re using such a plugin as there’s a risk that you will ban legitimate users.
Download
spam-log-0.1.tar.gz
spam-log-0.1.zip
[...] Read more from the original source: Integrate fail2ban with bWordPress/b: bSpam/b Log Plugin | Random Bits [...]
[...] Source:Integrate fail2ban with WordPress: Spam Log Plugin [...]
[...] Integrate fail2ban with WordPress: Spam Log Plugin [Random Bits]This is ubergeeky, but being able to block spammers is loads of fun. [...]
[...] Integrate fail2ban with WordPress: Spam Log Plugin [Random Bits]This is ubergeeky, but being able to block spammers is loads of fun. [...]
Thanks for that great plugin!
Using it with a lot of success so far!! :)
Even tho I have one question about the usage:
I am running more than one website on my server.
How is it possible to add more than one spam-log to it?
Right now the jail.conf points to one of the websites spam.log file.
Can I just add another one of those into the jail.conf or won’t it work:
[spam-log]
enabled = true
port = http,https
filter = spam-log
logpath = /path/to/spam.log
maxretry = 5
findtime = 3600
bantime = 86400
Thanks in advance,
Joern
I think that will work although I personally haven’t tried.
You will probably have the change the name (“[spam-log]“) and the path to the log (“logpath = /path/to/spam.log”) for each separate entry in jail.conf.
If you have any problems, post again and I can probably figure it out.
Edit: Also, it looks fail2ban > 0.7 supports wildcards in the logpath directive. So, another options would be something like “logpath = /path/to/sites/*/spam.log” where * gets expanded to site1, site2, site3, etc.
That might be easier depending on your directory structure and the number of sites.
It works great!
I chose the first option you wrote down and it works like a charm.
Gonna try the wildcard-version too.
Thanks a lot for your help!!
I really appreciate it!
It works so good a small update about that plugin will help us to be save.
It really works.
This spam log plugin will save a lot of time on my big blog .
mister cartoon flash,
Business – a motor mechanism, appliance, intended for the carriage of goods, towing trailers, trailers (not a farm tractor) or to schlep people (and not a bus) with a pardonable slews of across 3500 kg.
Transporter may outdo a person with a area C (in search appear trucks GVW from 3.5 to 7.5 tons is satisfactorily category C1). In the state of combinations of vehicles (lorry with trailer or semi-trailer) is also required to have a license group E.
There is also a pressure acutance, which defines the principle of the car for the sundries for companies seeking to remove VAT on the acquisition price. It defines the “Law on contribution on goods and services”.
Chłodnia
In North America (U.S. and Canada), the sundries is a channel with a allowable all-out authority exceeding 26,000 pounds, or regarding 11700 kg. It can be carried minus after obtaining a commission called the English: Commercial Driver License.
my site…
[...]Integrate fail2ban with WordPress: Spam Log Plugin | Random Bits[...]…
hosting
Wypatrujesz prostego i opłacalnego wyjścia, iżby zwiększyć dochody osobistej firmy? Mam zatem dla Ciebie inteligentne wyjście. Reklama. Wiem, miało być bez zbytnich kosztów, jednak przynoszę Ci pewność, iż tak będzie. Najprostszą i w najwyższym stopniu całościową, acz w tym samym czasie w największym stopniu wydajną jakością reklamy jest witryna. W tym momencie, jeśliby Twojej firmy nie ma w Necie to możesz zapomnieć o sporych zyskach. Każdy wypatruje najpierw w sieci, dopiero potem możliwie sięga po ogłoszenia w gazecie, lub pyta znajomych. Popatrzmyż prawdzie w oczy, strona jest de facto konieczne. Jeżeli nie jesteś znający się w sprawach domen i Internetu nie obawiaj się. Nasza firma wstała z tej przyczyny szczególnie dla Ciebie. Przekazujemy usługi z obrębu hosting od początku do finału. Nasi koneserzy odpowiedzą na Twoje wszystkie zapytania i pomogą dobrać najlepszą ofertę dla Ciebie. Dzięki nam możesz wzmóc dochody swojej firmy przy w rzeczy samej mizernym nakładzie płatniczym. Jakim sposobem? Przez wzgląd usługi hosting. Zaznajomisz się tutaj z kompletną ofertą na hosting i przyuważysz dane do kontaktu z nami. Sprawdź w jaki sposób Internet może Cię wesprzeć.
mielno Jeśli pragniesz wybrać się w tym roku nad nasze morze, to warto zdecydować się na odwiedzenie niedużego Mielna. Na Wybrzeżu Słowińskim leży jedno bardzo atrakcyjne miasteczko niegdyś rybackie czyli Mielno. Polacy bardzo często w trakcie urlopu wyruszają do Mielna wspólnie ze swoimi znajomymi. Do Mielna przyjeżdżają turyści nie wyłącznie z naszego kraju, natomiast z całego świata, albowiem to jeden z najpopularniejszych Polskich kurortów. Do Mielna wyruszają turyści wespół z rodziną czy też ze znajomymi, a także urządzane są obozy dla młodzieży. Noclegi Mielno znajdują się na rzeczywiście wysokim poziomie, przy swojej niskiej ceny. Każda osoba, którą znam twierdzi, iż wakacje to niepowtarzalny okres podczas całego roku. Wobec wakacyjnego wyjazdu mamy wiele postulowań. Powinniśmy się nie tylko idealnie bawić wraz z najbliższymi oraz także powrócić wypoczęci. Mielno umożliwia nam znakomitą zabawę. Funkcjonuje w tej miejscowości dużo fascynujących dyskotek, do których można wybrać się ze znajomymi i pobawić. Atrakcyjne noclegi Mielno to pola namiotowe oraz domki kempingowe w najlepszych punktach tego kurortu. Jest to niezwykle dobra oferta dla osób z mniejszą ilością gotówki czyli dla młodych ludzi. Każdego roku w ciągu wakacji nad Polskie morze wybiera się aż 8 milionów podróżników z naszego kraju i z zagranicy.
wordpress blog hosting…
[...]Integrate fail2ban with WordPress: Spam Log Plugin | Random Bits[...]…
whoah this blog is wonderful i really like studying your articles. Keep up the good paintings! You understand, many people are hunting around for this information, you could help them greatly.
how to improve spoken english online free…
[...]Integrate fail2ban with WordPress: Spam Log Plugin | Random Bits[...]…