Giter Club home page Giter Club logo

semalt-blocker's Introduction

Don't use this project

The list of spammy domains is stale and without any update since 2016

Read original blogpost which inspired this project: Semalt infecting computers to spam the web.


Latest Stable Version Build Status Coverage Status Scrutinizer Code Quality StyleCI Status Dependency Status Packagist Downloads License

semalt-blocker

Self-updating PHP library which blocks hundreds of spammy domains from ruining your website statistics

Bad domains Last updated
2433 December 1st, 2016

Block referral spam with a single line of code. Originally started to stop the nasty Semalt botnet from visiting your site and ruining your stats (of course their domains are still included), the blocklist now contains hundreds of spammy domains. The library will try to self-update every week, so you don't have to worry about composer update's.

blocklist

Looking for the blocklist only? No problem:

sources

The blocklist is compiled from several sources. Currently:

Source Raw source file Number of domains
sahava https://raw.githubusercontent.com/sahava/spam-filter-tool/master/js/spamfilter.js 417
piwik https://raw.githubusercontent.com/piwik/referrer-spam-blacklist/master/spammers.txt 483
stevie-ray https://raw.githubusercontent.com/Stevie-Ray/apache-nginx-referral-spam-blacklist/master/generator/domains.txt 1071
ar-communications https://raw.githubusercontent.com/ARCommunications/Block-Referral-Spam/master/blocker.php 376
flameeyes https://raw.githubusercontent.com/Flameeyes/modsec-flameeyes/master/rules/flameeyes_bad_referrers.data 936
semalt-blocker ../domains/additional 1
desbma https://raw.githubusercontent.com/desbma/referer-spam-domains-blacklist/master/spammers.txt 1700

debug console

We've added a tool to check whether your site blocks spammy bots. You can find it in the repository and online at: nabble.nl/semalt

composer setup

This is the easiest method, but requires the use of Composer. Add semalt-blocker to your project by running the following in your terminal:

composer require nabble/semalt-blocker:~1

Then in your project add (but you probably already have this):

require "vendor/autoload.php";

legacy setup

Not using composer? No problem, copy the files domains/blocked and compact/semaltblocker.php to the same directory in your project and add this line:

require "/path/to/semaltblocker.php";

basic usage

It's as easy as:

use Nabble\SemaltBlocker\Blocker;

Blocker::protect();

// ... your app

Make sure you add it somewhere at the beginning of your code, it will save you!

self-update

In order for the self-update mechanism to work, make sure the domains/blocked file is writable by the webserver:

$ chmod a+w vendor/nabble/semalt-blocker/domains/blocked

options

Blocker::protect(); // default, serve a 403 Forbidden response
Blocker::protect('http://semalt.com'); // return them their own botnet traffic
Blocker::protect('Hi, bot'); // displays a nice message when blocked

All calls to the protect function will trigger the auto-updater at a regular interval.

If you want to stay in control even more, use this:

$blocked = Blocker::blocked(); // returns true when a blocked referrer is detected

If you want an explanation for why a referer is blocked, use:

echo Blocker::explain();

The self-updater runs every 7 days by default. To force updating the domain list, use this:

use Nabble\SemaltBlocker\Updater;

Updater::update(true);

contribute

Yes, please! Feel free to open issues or pull-requests.

licence

MIT

semalt-blocker's People

Contributors

alister avatar hongaar avatar scrutinizer-auto-fixer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

semalt-blocker's Issues

Info requested

Hi all,
I would like to ask if any manual is available to set up your script in an hosted site.
Actually I use the scripts manually uploading to .htaccess (my site is hosted on dreamhost with apache engine)
Actually my .htaccess is growing tooooooo much and speed down my site (e-commerce site)
Thank you in advance
Boris

Implement subdomain matching

Right now, subdomains are stripped before importing blocklist and before doing any comparison between referer <-> blocklist. (i.e. right now mozilla.org is on the blocklist)

Current situation:

Source Blocklist Referer Blocked
addons.mozilla.org/.../... mozilla.org *.mozilla.org Y
urlopener.blogspot.com.au blogspot.com.au *.blogspot.com.au Y
semalt.com semalt.com 43.semalt.com Y

New situation:

Source Blocklist Referer Blocked
addons.mozilla.org/.../... - *.mozilla.org N
urlopener.blogspot.com.au urlopener.blogspot.com.au urlopener.blogspot.com.au Y
semalt.com semalt.com 43.semalt.com Y

Add own referer

Hello,

so far, your scripts work without problem! Thanks for coding it!

I do have a question though: is it possible to provide a file which contains additional referer for blocking and which is not overwritten by autoupdate ?

Thanks!

Dragon013

Update to php-domain-parser ~3.0 (require-dev)

First, why is needed the php-domain-parser? I have not found anything.
If required, is it possible to go to version 3.0?

A Symfony application uses the version 3.0 and thus I get a conflict when the dev dependencies are installed.

    "require-dev": {
        "jeremykendall/php-domain-parser": "~3.0",
        ...

Path setting domain/blocked

How to set the path setting for the dir domain/blocked for the legacy setup ?

I tried this and that seems to work but not for the updater

\Nabble\SemaltBlocker\Blocker::$blocklist = '../domains/blocked';

Non-coder instructions & integration with WordPress

It would be a huge help if you could write up instructions for people who are not programmers so that we might use your code in WordPress installations. Just a little bit about where best to place the code and how it works from the standpoint of a layperson :) Thanks! -TC

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.