diff --git a/app/Http/Controllers/HumanVerification.php b/app/Http/Controllers/HumanVerification.php index d304fc1b36e8619c1ef61a6632716e9f201c527a..c9a352320fd26a72f7d70be3ef54f00d4580c786 100644 --- a/app/Http/Controllers/HumanVerification.php +++ b/app/Http/Controllers/HumanVerification.php @@ -90,6 +90,30 @@ class HumanVerification extends Controller } + public static function logCaptcha(Request $request){ + $fail2banEnabled = config("metager.metager.fail2ban_enabled"); + if(empty($fail2banEnabled) || !$fail2banEnabled || !env("fail2banurl", false) || !env("fail2banuser") || !env("fail2banpassword")){ + return; + } + + // Submit fetch job to worker + $mission = [ + "resulthash" => "captcha", + "url" => env("fail2banurl") . "/captcha/", + "useragent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0", + "username" => env("fail2banuser"), + "password" => env("fail2banpassword"), + "headers" => [ + "ip" => $request->ip() + ], + "cacheDuration" => 0, + "name" => "Captcha", + ]; + $mission = json_encode($mission); + Redis::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission); + + } + public static function remove(Request $request) { if (!$request->has('mm')) { diff --git a/app/Http/Middleware/HumanVerification.php b/app/Http/Middleware/HumanVerification.php index 43997ee9ee90585bcce2a480bd8cfbefb35a077f..47e06200c8dd811069ce46f496f6a985b54ca007 100644 --- a/app/Http/Middleware/HumanVerification.php +++ b/app/Http/Middleware/HumanVerification.php @@ -46,7 +46,7 @@ class HumanVerification * If someone that uses a bot finds this out we * might have to change it at some point. */ - if ($request->filled('appversion') || !env('BOT_PROTECTION', false) || app('App\Models\Key')->getStatus()) { + if (!env('BOT_PROTECTION', false) || app('App\Models\Key')->getStatus()) { $update = false; return $next($request); } @@ -103,6 +103,7 @@ class HumanVerification # If the user is locked we will force a Captcha validation if ($user["locked"]) { + \App\Http\Controllers\HumanVerification::logCaptcha($request); return redirect()->route('captcha', ["id" => $id, "uid" => $uid, "url" => url()->full()]); } diff --git a/config/metager/metager.php b/config/metager/metager.php index 8db1e8fe50f6f7714d64d4b82c892518b17845a1..4e61c3d76fcfe1100a619bc8712499b5585e1cc4 100644 --- a/config/metager/metager.php +++ b/config/metager/metager.php @@ -1,8 +1,9 @@ <?php return [ - "browserverification_enabled" => true, + "browserverification_enabled" => false, "browserverification_whitelist" => [ "w3m\/", ], + "fail2ban_enabled" => true, ];