Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
open-source
MetaGer
Commits
30b5a87e
Commit
30b5a87e
authored
Jun 04, 2019
by
Dominik Hebeler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refined bot protection
parent
51965b64
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
28 deletions
+25
-28
app/Http/Controllers/StartpageController.php
app/Http/Controllers/StartpageController.php
+0
-24
app/Http/Middleware/HumanVerification.php
app/Http/Middleware/HumanVerification.php
+25
-2
routes/web.php
routes/web.php
+0
-2
No files found.
app/Http/Controllers/StartpageController.php
View file @
30b5a87e
...
...
@@ -115,28 +115,4 @@ class StartpageController extends Controller
->
with
(
'link'
,
$link
)
->
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
];
}
}
app/Http/Middleware/HumanVerification.php
View file @
30b5a87e
...
...
@@ -7,6 +7,7 @@ use Closure;
use
Cookie
;
use
Illuminate\Http\Response
;
use
Illuminate\Support\Facades\Redis
;
use
Log
;
use
URL
;
class
HumanVerification
...
...
@@ -26,8 +27,9 @@ class HumanVerification
$prefix
=
"humanverification"
;
$redis
=
Redis
::
connection
(
'redisCache'
);
try
{
$id
=
hash
(
"sha512"
,
$request
->
ip
());
$uid
=
hash
(
"sha512"
,
$request
->
ip
()
.
$_SERVER
[
"AGENT"
]
.
"uid"
);
$ip
=
$this
->
getIP
();
$id
=
hash
(
"sha512"
,
$ip
);
$uid
=
hash
(
"sha512"
,
$ip
.
$_SERVER
[
"AGENT"
]
.
"uid"
);
unset
(
$_SERVER
[
"AGENT"
]);
/**
...
...
@@ -180,4 +182,25 @@ class HumanVerification
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
;
}
}
}
routes/web.php
View file @
30b5a87e
...
...
@@ -22,8 +22,6 @@ Route::group(
Route
::
get
(
'/'
,
'StartpageController@loadStartPage'
);
Route
::
get
(
'test2'
,
'StartpageController@testTor'
);
Route
::
get
(
'asso'
,
function
()
{
return
view
(
'assoziator.asso'
)
->
with
(
'title'
,
trans
(
'titles.asso'
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment