Commit f6b9ffa4 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

added f2b to spam

parent 65a866de
......@@ -6,6 +6,7 @@ use App\Models\HumanVerification;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Redis;
use Jenssegers\Agent\Agent;
class Spam
{
......@@ -35,10 +36,15 @@ class Spam
}
if ($spam === true) {
$browser = new Agent();
if ($browser === "Chrome" && $browser->version($browser) === "91.0.4472.77") {
$this->logFail2Ban($request->ip());
}
// ToDo Remove Log
$file_path = \storage_path("logs/metager/spam.csv");
$fh = fopen($file_path, "a");
try {
$data = [
now()->format("Y-m-d H:i:s"),
$request->input("eingabe", ""),
......@@ -50,6 +56,7 @@ class Spam
} finally {
fclose($fh);
}
/*
$human_verification = \app()->make(HumanVerification::class);
$human_verification->lockUser();
......@@ -60,4 +67,28 @@ class Spam
return $next($request);
}
private function logFail2Ban($ip)
{
$fail2banEnabled = config("metager.metager.fail2ban.enabled");
if (empty($fail2banEnabled) || !$fail2banEnabled || !config("metager.metager.fail2ban.url") || !config("metager.metager.fail2ban.user") || !config("metager.metager.fail2ban.password")) {
return;
}
// Submit fetch job to worker
$mission = [
"resulthash" => "browserverification.ban",
"url" => config("metager.metager.fail2ban.url") . "/spam/",
"useragent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
"username" => config("metager.metager.fail2ban.user"),
"password" => config("metager.metager.fail2ban.password"),
"headers" => [
"ip" => $ip()
],
"cacheDuration" => 0,
"name" => "Captcha",
];
$mission = json_encode($mission);
Redis::rpush(\App\MetaGer::FETCHQUEUE_KEY, $mission);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment