There is no way to defend yourself efficiently and VPN is impossible (as far as I understand), the only way would be to have a list of Ips that is provided by some service, however this is not quite a case of programming necessarily, I don’t know any kind of service that provides these lists, but the way is probably this.
However some proxies pass data on HTTP, which may help to check this, I did not find many details of headers, as not all are standardized, however this chat on wikipedia tries to give or get some guidance: https://en.wikipedia.org/wiki/Talk%3AX-Forwarded-For, follows some details:
The header "Via" which is used by gateways and proxies to indicate the intermediate protocols and recipients between the "user agent" and the server about the requests, and between the source server and the client in the responses, use in PHP:
Details about Forwarded:
https://tools.ietf.org/html/rfc7239#Section-5.2, use in PHP:
HTTP_FORWARDED_FOR
HTTP_FORWARDED
HTTP_X_FORWARDED_FOR
(was probably used before the HTTP_FORWARDED_FOR
, when it was still experimental)
HTTP_X_FORWARDED
(was probably used before the HTTP_FORWARDED_FOR
, when it was still experimental)
The X-Cluster-Client-IP:
which apparently is required by the Zeus web servers:
The Client-IP:
I couldn’t find any information, what it seems to me is that it was used before the Forwarded:
, use in PHP:
HTTP_CLIENT_IP
HTTP_X_CLIENT_IP
(variation of HTTP_CLIENT_IP
)
Detecting if you are using a proxy that passes header(s)
In PHP it would look something like:
<?php
function isProxy()
{
$proxyTypes = array(
'HTTP_VIA',
'HTTP_FORWARDED_FOR',
'HTTP_FORWARDED',
'HTTP_X_FORWARDED_FOR',
'HTTP_X_FORWARDED',
'HTTP_X_CLUSTER_CLIENT_IP',
'HTTP_CLIENT_IP',
'HTTP_X_CLIENT_IP'
);
foreach ($proxyType as $proxyTypes) {
if (!empty($proxyType)) {
return true;
}
}
return false;
}
if (isProxy()) {
//Finaliza o script PHP e emite uma mensagem, pode customizar essa if como desejar
die('Você está usando proxy');
}
Detecting if you are using a web-proxy:
Web-proxies usually use frames, so it is possible to only check if your page is running inside a <iframe>
or <frame>
, add so in page footer:
<script>
function detectLoadInFrame()
{
//O try previne problemas de bloqueios de CORS
try {
if (window.self !== window.top) {
window.top.location = window.location;
}
} catch (e) {
}
}
</script>
</body>
</html>
But note that sometimes web-proxies block Javascript, this causes problems when making the detection, so the interesting thing would be to block some main HTML functionality, such as navbar, or a form, for example:
css style.:
.navbar {
display: none;
}
.navbar.show {
display: block;
}
Your html:
<html>
<head>
<link href="estilo.css" rel="stylesheet" type="text/css">
</head>
<body>
<nav class="navbar">
<a href="...">...</a>
</nav>
<form id="meuform">
<input type="text" disabled>
<select disabled></select>
</form>
<script>
function detectLoadInFrame()
{
//O try previne problemas de bloqueios de CORS
try {
if (window.self !== window.top) {
window.top.location = window.location;
} else {
//Exibe o navbar
document.querySelector(".navbar").className += " show";
//Habilita os campos
var fields = document.querySelectorAll("#meuform [disabled]");
for (var i = fields.length - 1; i >= 0; i--) {
fields[i].disabled = false;
}
}
} catch (e) {
}
}
</script>
</body>
</html>
This might help you: https://medium.com/@Valdikss/Detecting-vpn-and-its-Configuration-and-proxy-users-on-the-server-side-1bcc59742413#. rmi42s248
– MagicHat