Commit 30b5a87e authored by Dominik Hebeler's avatar Dominik Hebeler

refined bot protection

parent 51965b64
...@@ -115,28 +115,4 @@ class StartpageController extends Controller ...@@ -115,28 +115,4 @@ class StartpageController extends Controller
->with('link', $link) ->with('link', $link)
->with('password', $password); ->with('password', $password);
} }
public function testTor()
{
if ($this->IsTorExitPoint()) {
die(var_dump("Willkommen Tor"));
} else {
die(var_dump("Willkommen Normal"));
}
}
private function IsTorExitPoint()
{
if (gethostbyname($this->ReverseIPOctets($_SERVER['REMOTE_ADDR']) . "." . $_SERVER['SERVER_PORT'] . "." . $this->ReverseIPOctets($_SERVER['SERVER_ADDR']) . ".ip-port.exitlist.torproject.org") == "127.0.0.2") {
return true;
} else {
return false;
}
}
private function ReverseIPOctets($inputip)
{
$ipoc = explode(".", $inputip);
return $ipoc[3] . "." . $ipoc[2] . "." . $ipoc[1] . "." . $ipoc[0];
}
} }
...@@ -7,6 +7,7 @@ use Closure; ...@@ -7,6 +7,7 @@ use Closure;
use Cookie; use Cookie;
use Illuminate\Http\Response; use Illuminate\Http\Response;
use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Redis;
use Log;
use URL; use URL;
class HumanVerification class HumanVerification
...@@ -26,8 +27,9 @@ class HumanVerification ...@@ -26,8 +27,9 @@ class HumanVerification
$prefix = "humanverification"; $prefix = "humanverification";
$redis = Redis::connection('redisCache'); $redis = Redis::connection('redisCache');
try { try {
$id = hash("sha512", $request->ip()); $ip = $this->getIP();
$uid = hash("sha512", $request->ip() . $_SERVER["AGENT"] . "uid"); $id = hash("sha512", $ip);
$uid = hash("sha512", $ip . $_SERVER["AGENT"] . "uid");
unset($_SERVER["AGENT"]); unset($_SERVER["AGENT"]);
/** /**
...@@ -180,4 +182,25 @@ class HumanVerification ...@@ -180,4 +182,25 @@ class HumanVerification
return $next($request); return $next($request);
} }
private function getIP()
{
$ip = \Request::ip();
$serverAddress = empty($_SERVER['SERVER_ADDR']) ? "144.76.88.77" : $_SERVER['SERVER_ADDR'];
$queryUrl = "https://tor.metager.org?password=" . urlencode(env("TOR_PASSWORD")) . "&ra=" . urlencode($ip) . "&sa=" . urlencode($serverAddress) . "&sp=443";
$ch = curl_init($queryUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpcode === 200) {
Log::info("Tor call");
return "999.999.999.999";
} else {
return $ip;
}
}
} }
...@@ -22,8 +22,6 @@ Route::group( ...@@ -22,8 +22,6 @@ Route::group(
Route::get('/', 'StartpageController@loadStartPage'); Route::get('/', 'StartpageController@loadStartPage');
Route::get('test2', 'StartpageController@testTor');
Route::get('asso', function () { Route::get('asso', function () {
return view('assoziator.asso') return view('assoziator.asso')
->with('title', trans('titles.asso')) ->with('title', trans('titles.asso'))
......
Markdown is supported
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