seanhayes-com / laravel-probe-detection
一个用于记录已知网站探测攻击的 Laravel 扩展包。
0.3
2020-02-17 16:45 UTC
Requires
- php: ^7.2
- laravel/framework: ^6.0
- torann/geoip: ^1.1
Requires (Dev)
- league/flysystem: >=1.0.8
- mockery/mockery: ^1.0
- orchestra/testbench: ^4.0
- phpunit/phpunit: ^8.0
README
记录和阻止已知的网站探测攻击,消除浪费的网站资源
最低要求
Laravel 6.0 和 PHP 7.2
安装
您可以通过 composer 安装此包
composer require seanhayes-com/laravel-probe-detection
包将自动注册自己。
您可以使用以下命令发布迁移
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 中更改设置
将路由添加到处理某些常见攻击向量或 URI,或将其添加到 config/probe.php 中的 watch_uris
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