kjeittccdf 发表于 2015-3-28 01:42:31

绕过代理获取访客真实IP| →『网络安全区』

Firefox 跟 Chrome支持WebRTC可以向STUN服务器请求,返回内外网IP,不同于XMLHttpRequest请求,STUN请求开发者工具当中看不到网络请求的。

//get the IP addresses associated with an account
function getIPs(callback){
    var ip_dups = {};

    //compatibility for firefox and chrome
    var RTCPeerConnection = window.RTCPeerConnection
      || window.mozRTCPeerConnection
      || window.webkitRTCPeerConnection;
    var mediaConstraints = {
      optional: [{RtpDataChannels: true}]
    };

    //firefox already has a default stun server in about:config
    //    media.peerconnection.default_iceservers =
    //    [{"url": "stun:stun.services.mozilla.com"}]
    var servers = undefined;

    //add same stun server for chrome
    if(window.webkitRTCPeerConnection)
      servers = {iceServers: [{urls: "stun:stun.services.mozilla.com"}]};

    //construct a new RTCPeerConnection
    var pc = new RTCPeerConnection(servers, mediaConstraints);

    //listen for candidate events
    pc.onicecandidate = function(ice){

      //skip non-candidate events
      if(ice.candidate){

            //match just the IP address
            var ip_regex = /({1,3}(\.{1,3}){3})/
            var ip_addr = ip_regex.exec(ice.candidate.candidate);

            //remove duplicates
            if(ip_dups === undefined)
                callback(ip_addr);

            ip_dups = true;
      }
    };

    //create a bogus data channel
    pc.createDataChannel("");

    //create an offer sdp
    pc.createOffer(function(result){

      //trigger the stun server request
      pc.setLocalDescription(result, function(){});

    }, function(){});
}

//Test: Print the IP addresses into the console
getIPs(function(ip){console.log(ip);});

发表于 2015-3-31 11:53:42

真的 好久都没有这么笑了~ 好开心哦

发表于 2015-3-31 11:45:27

你这样的表现,就只配这几个字:窝囊废

发表于 2015-3-31 11:44:09

激动了就不好办了..

发表于 2015-3-31 11:38:45

我起来了 哈哈 刚才迷了会

发表于 2015-3-31 11:54:05

我不知道他说的是什么啊~~

发表于 2015-4-21 11:40:16

今天统计好像出了问题

发表于 2015-4-21 11:23:52

机会就像水中的鱼,耐心等待就能上钩。

发表于 2015-4-21 11:40:25

回来了 呵呵刚才在斗地主那 ~~~~

发表于 2015-4-21 11:26:04

你可是难得来坐坐啊~~~

发表于 2015-4-21 11:14:26

朕在自己的寝宫~~~~

发表于 2015-5-5 16:04:41

感觉楼主说的很不错,我也很赞同

发表于 2015-5-5 16:11:49

如本人留言违反国家有关法律,请网络管理员及时删除本人跟贴。本回贴不暗示、鼓励、支持或映射读者作出生活方式、工作态度、婚姻交友、子女教育的积极或消极判断。

发表于 2015-5-5 16:14:31

估计你是没见识过~` 呵呵

发表于 2015-5-5 16:21:15

你可是难得来坐坐啊~~~
页: [1] 2
查看完整版本: 绕过代理获取访客真实IP| →『网络安全区』