2017 © Pedro Peláez
 

application defender

Defend your site from malicious scans

image

hongliang/defender

Defend your site from malicious scans

  • Thursday, July 12, 2018
  • by h-wang
  • Repository
  • 2 Watchers
  • 3 Stars
  • 92 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 9 Versions
  • 5 % Grown

The README.md

Scrutinizer Code Quality Build Status, (*1)

Defender

Defend your site from malicious scans. It works with defense voters. Currently request URI keyword and IP range defense voters are supported., (*2)

Installation

Install via composer, (*3)

composer require hongliang/defender

How it works

If you are running a Silex or Symfony application, the following code should be injected after the autoload but before the routers. Otherwise it will trigger an undefined route exception., (*4)

The simple way:, (*5)

\Hongliang\Defender\Defender::defend();

The customized way:, (*6)

use Hongliang\Defender\Defender;
use Hongliang\Defender\Voter\IpRangeVoter;
use Hongliang\Defender\Voter\UriKeywordVoter;

$defender = new Defender();
$defender->addVoter(new IpRangeVoter())
    ->addVoter(new UriKeywordVoter())
    ->react();

Customize to your own needs:, (*7)

use Hongliang\Defender\Defender;
use Hongliang\Defender\Voter\IpRangeVoter;
use Hongliang\Defender\Voter\UriKeywordVoter;
use Hongliang\Defender\Voter\SpiderVoter;

// it's possible to customize the level of reaction as the 2nd parameter of addVoter()
// it's possible to set a URL to redirect to when the level is revenge or higher. By default it's localhost
$defender = new Defender();
$defender->addVoter(new IpRangeVoter(), Defender::FORBIDDEN)
    ->addVoter(new UriKeywordVoter(), Defender::REVENGE)
    ->addVoter(new SpiderVoter(), Defender::DENY)
    ->setRedirectUrl('http://www.google.com')
    ->react();

More advanced use:, (*8)

use Hongliang\Defender\Defender;
use Hongliang\Defender\Voter\IpRangeVoter;
use Hongliang\Defender\Voter\UriKeywordVoter;
use Hongliang\Defender\Voter\SpiderVoter;

$voter = new UriKeywordVoter();
$voter->setAssets(['fckedit', '/wp-']);
$ipVoter = new IpRangeVoter();
$ipVoter->setAssets([['0.0.0.0', '255.255.255.255']]);

$spiderVoter = new SpiderVoter();
$spiderVoter->setAssets(['Baiduspider', '360spider']);

$defender = new Defender();
$defender->addVoter($ipVoter, Defender::FORBIDDEN)
    ->addVoter($voter, Defender::DENY)
    ->addVoter($spiderVoter, Defender::DENY)
    ->react();

TODO

  • [x] Separate IP ranges into separate file or even external resource
  • [x] Build IP ranges into long integer for better performance
  • [ ] Support logging and log everything that's above the normal level
  • [ ] Separate URI keywords into categories, e.g. Wordpress, Joomla. This way it's possible to be used in those CMSes.

The Versions

12/07 2018

dev-master

9999999-dev https://github.com/h-wang/defender

Defend your site from malicious scans

  Sources   Download

MIT

security bot scan hongliang defender

12/07 2018

v0.2.6

0.2.6.0 https://github.com/h-wang/defender

Defend your site from malicious scans

  Sources   Download

MIT

security bot scan hongliang defender

08/03 2018

v0.2.5

0.2.5.0 https://github.com/h-wang/defender

Defend your site from malicious scans

  Sources   Download

MIT

security bot scan hongliang defender

01/03 2018

v0.2.4

0.2.4.0 https://github.com/h-wang/defender

Defend your site from malicious scans

  Sources   Download

MIT

security bot scan hongliang defender

26/10 2017

v0.2.3

0.2.3.0 https://github.com/h-wang/defender

Defend your site from malicious scans

  Sources   Download

MIT

security bot scan hongliang defender

17/04 2016

v0.2.2

0.2.2.0 https://github.com/h-wang/defender

Defend your site from malicious scans

  Sources   Download

MIT

security bot scan hongliang defender

30/03 2016

v0.2.1

0.2.1.0 https://github.com/h-wang/defender

Defend your site from malicious scans

  Sources   Download

MIT

security bot scan hongliang defender

29/03 2016

v0.2.0

0.2.0.0 https://github.com/h-wang/defender

Defend your site from malicious scans

  Sources   Download

MIT

security bot scan hongliang defender

25/03 2016

v0.1.0

0.1.0.0 https://github.com/h-wang/defender

Defend your site from malicious scans

  Sources   Download

MIT

security bot scan hongliang defender