代理检测 [英] Proxy detection

查看:101
本文介绍了代理检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代理操作标题,所以我决定使用js和php检查页面地址,如果它们相等=>没有代理. 但是我认为我的实现是不正确的.

Proxies manipulate headers ,so I decided to check page address with js and php and if they are equal => no proxy. But I think that my implementation isn't correct.

    <script src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
<div id="JS" style="display:none">
<script>



</script>
</div>
<div id="noJS">Enable JS</div>
<script>
$(document).ready(function() {
$("#noJS").hide();
$("#JS").show().addClass("hasJS");  
if($("#JS").hasClass("hasJS")) {

    if($("#addrphp").text() == location.href) {
        alert("no proxy");
    }
    else {
        alert("proxy")

    }

}   
});
</script>
<?php
$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
?>
<div id="addrphp" style="display:none;"><?php echo $url; ?></div>

您怎么看?这会阻止大多数代理吗?我的实现是否正确(这是做我想要的最好方法)?

What do you think?Is that going to stop most proxies?Is my implementation correct(is that the best way of doing what I want)?

推荐答案

除非您使用的是Google缓存之类的代理,否则代理不会更改浏览器所请求页面的地址.代理仅接受您的请求,为您获取请求中任何地址的内容,然后将答复转发给您的计算机.它绝对不会更改地址,因为那意味着您所请求的不是您所得到的.

A proxy doesn't change the address of the page your browser's requesting, unless you're using something like Google cache. The proxy simply accepts your request, fetches the contents of whatever address is in the request for you, and forwards the reply to your machine. At no point should it change the address, as that'd mean what you've requested is not what you're getting.

如果Java中提供了本地IP,则可以简单地检查请求来自的地址是否与Java中检测到的地址匹配,但是Java无法处理该底层网络概念.一个签名的Java applet可以,也可以是Flash/Silverlight applet,尽管我只是在猜测那些.

If the local IP was available in Javascript, you could trivially check that the address the request comes from matches the address detected in Javascript, but Javascript cannot deal with that low-level a networking concept. A signed Java applet could, and maybe a Flash/Silverlight applet as well, though I'm just guessing on those.

但是,使用家庭宽带路由器这样的琐碎检查IP地址也会失败. 本地" IP很可能类似于10.0.0.13,但是您的站点将检测到该请求来自路由器的外部地址.没有涉及代理",只是一个NAT网关,但是请求IP!=客户端IP,哇,您被代理了,伙计!

But checking IP addresses will fail as well with something as trivial as a home broadband router. The "local" IP could very well be something like 10.0.0.13, but your site will detect the request as coming from whatever the router's external address is. There's no "proxy" involved, simply a NAT gateway, but request IP != client IP and woah, you're proxied, dude!

最可靠(但仍然不是特别可靠)的方法是检查各种代理标头,例如X-Forwarded-For.

The most reliable (and still not particularly reliable at all) method is to check for the various proxy headers, such as X-Forwarded-For.

这篇关于代理检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆