seanhayes-com/laravel5-probe-detection

一个用于记录已知网站探测攻击的 Laravel 5 包。

0.1.2 2020-02-17 21:53 UTC

This package is auto-updated.

Last update: 2024-09-19 01:16:50 UTC


README

记录并禁止已知的网站探测攻击,消除浪费的网站资源

最低要求

Laravel 5.1 和 PHP 5.5.9

安装

您可以通过 composer 安装此包

composer require seanhayes-com/laravel5-probe-detection

步骤 2:配置

将以下内容添加到您的 config/app.php 文件的 providers 数组中

SeanHayes\Probe\ProbeServiceProvider::class,
Torann\GeoIP\GeoIPServiceProvider::class,

您还应该将以下内容添加到 aliases 数组中

'Probe'     => SeanHayes\Probe\ProbeFacade::class,
'GeoIP'     => Torann\GeoIP\GeoIPFacade::class,

然后您可以使用以下命令发布迁移

php artisan vendor:publish --provider="SeanHayes\Probe\ProbeServiceProvider" --tag="migrations"

迁移发布后,您可以通过运行迁移来创建 prob_log

php artisan migrate

您还可以选择使用以下命令发布配置文件

php artisan vendor:publish --provider="SeanHayes\Probe\ProbeServiceProvider" --tag="config"

配置

在 config/probe.php 中更改设置

在 config/probe.php 中添加路由以处理某些常见的攻击向量或 URI

Route::get('/wp-login.php', function () {
	\SeanHayes\Probe\Probe::logRequest();
});
Route::get('/{name}/wp-login.php', function () {
	\SeanHayes\Probe\Probe::logRequest();
});
Route::get('/wp-admin/', function () {
	\SeanHayes\Probe\Probe::logRequest();
});
Route::get('/wp-content/', function () {
	\SeanHayes\Probe\Probe::logRequest();
});
Route::get('/{name}/wp-admin/', function () {
	\SeanHayes\Probe\Probe::logRequest();
});
Route::get('/xmlrpc.php', function () {
	\SeanHayes\Probe\Probe::logRequest();
});
Route::get('/wp-cron.php', function () {
	\SeanHayes\Probe\Probe::logRequest();
});
Route::post('/wp-login.php', function () {
	\SeanHayes\Probe\Probe::logRequest();
});
Route::post('/{name}/wp-login.php', function () {
	\SeanHayes\Probe\Probe::logRequest();
});
Route::post('/wp-admin/', function () {
	\SeanHayes\Probe\Probe::logRequest();
});
Route::post('/{name}/wp-admin/', function () {
	\SeanHayes\Probe\Probe::logRequest();
});
Route::post('/xmlrpc.php', function () {
	\SeanHayes\Probe\Probe::logRequest();
});
Route::post('/wp-cron.php', function () {
	\SeanHayes\Probe\Probe::logRequest();
});

用法

在 Controller 或 AppServiceProvider 中包含路径

use SeanHayes\Probe\Probe;

并在您的函数中调用处理请求

Probe::logRequest();

故障排除

如果您遇到文件缓存错误,您可以在 .env 文件中将 CACHE_DRIVER 更改为 array。

CACHE_DRIVER=array