Giter Site home page Giter Site logo

permikomnaskaltara / antiscanscanclub-laravel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from noobsec/antiscanscanclub-laravel

0.0 0.0 0.0 91 KB

A Laravel Package to Block Automated Scanners from Scanning your Site.

License: MIT License

PHP 100.00%

antiscanscanclub-laravel's Introduction

AntiScanScanClub

GitHub (pre-)release Build Status Total Downloads LICENSE GitHub issues GitHub closed pull requests Contributions Welcome

A Laravel Package to Block Automated Scanners from Scanning your Site.



Installation

$ composer require noobsec/antiscanscanclub-laravel

-- Please keep up-to-date this package to latest commit

Laravel 5+

Setup

  1. Publish the config file
php artisan vendor:publish --provider="noobsec\AntiScanScanClub\AntiScanScanClubServiceProvider"
  1. Create middleware
$ php artisan make:middleware AntiScanScanMiddleware

Configuration

  1. Add ASSC_LIST in .env file:

NOTE: Blacklists file will be stored in storage/app/ path

ASSC_LIST="blacklists.json"
  1. Edit the AntiScanScanMiddleware file (app/Http/Middleware/AntiScanScanMiddleware.php), approx like this:
<?php

namespace App\Http\Middleware;

use Closure;
use noobsec\AntiScanScanClub\AntiScanScanClub;

class AntiScanScanMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $ASSC = new AntiScanScanClub();
        $blocker = TRUE;
        $ASSC->checkIp($request->ip());

        if ($request->isMethod('GET') && $request->getQueryString() === NULL) {
            /**
             * Prevention of access to credentials and/ important files/path
             * (e.g: wp-admin.php, .git/, backups.tar.gz, www.sql)
             */

            $ASSC->filterFile($request->getPathInfo(), $blocker, $request->ip());
        } else {
            $ASSC->filterInput($request->all(), $blocker, $request->ip());
        }

        return $next($request);
    }
}
  1. Add middleware to global HTTP middleware stack, edit Kernel file (app/Http/Kernel.php):
    protected $middleware = [
        ...
        \App\Http\Middleware\AntiScanScanMiddleware::class,
    ];

Usage

  • Init AntiScanScanClub source
use noobsec\AntiScanScanClub\AntiScanScanClub;

$ASSC = new AntiScanScanClub();
  • Check whether the client IP has been blocked or not
$clientIp = '127.0.0.1';

var_dump($ASSC->checkIp($clientIp)); // @return void/bool
  • Add client IP to blacklists files
$clientIp = '127.0.0.1';
$attack_type = 'Added manually';

var_dump($ASSC->addToBlacklisted($clientIp, $attack)); // @return bool
  • Prevention of illegal input based on filter rules
$data = [
    "input" => "Test payload",
    "textarea" => "<object/onerror=write`1`//"
];
$blocker = TRUE;
$clientIp = '127.0.0.1';

$ASSC->filterInput($data, $blocker, $clientIp); // @return void/bool
  • Prevention of access to credentials and/ important files/path

e.g: wp-admin.php, .git/, backups.tar.gz, www.sql (see many more at filter_files.txt)

$url = "/wp-admin.php";
$blocker = TRUE;
$clientIp = '127.0.0.1';

$ASSC->filterFile($url, $blocker, $clientIp); // @return void/bool
  • Remove client IP from blacklists file
$clientIp = '127.0.0.1';

var_dump($ASSC->removeFromBlacklists($clientIp)); // @return bool
  • Purge and/ clean all client IPs from blacklists file
var_dump($ASSC->purgeBlacklistsFile()); // @return bool
  • Whitelisting one files/path from filterFile() rejection
var_dump($ASSC->whitelistFile('wp-admin.php')); // @return bool
  • Whitelisting all public files recursively from filterFile() rejection
var_dump(whitelistPublicFiles()); // @return array
  • Whitelisting uri of all registered routes from filterFile() rejection
var_dump(whitelistAllRoutes()); // @return array
  • Restoring filterFile() rules to default
var_dump($ASSC->restoreFilterFiles()); // @return bool
  • Add file and/ path to filterFile() rejection
$file = "api/adminLists";

var_dump(addToFilterFiles($file)); // @return integer/bool

NOTE

  • If you call filterInput() and/ filterFile() method, you no longer need to call addToBlacklisted() method.
  • Or if you want to call whitelistFile(), whitelistPublicFiles() and/ whitelistAllRoutes() method, make sure this is called before filterFile() and/ searchIp() method (or comment these methods, please check middleware).

Changelog

Please see the CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING.md for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

license. Please see the LICENSE file for more information.

Version

Current version is 2.0.2 and still development.

antiscanscanclub-laravel's People

Contributors

dwisiswant0 avatar noobsec avatar

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.