【转】禁用chrome firefox 的 WebRTC功能防止真实IP泄漏

无论是使用VPN还是其它代理方式,很多时候我们不希望暴露自己的真实IP,且一直以来我们认为VPN是安全的,所有流量都会走VPN。 
但最近暴露出一个WebRTC特性,会暴露我们的真实IP。适用浏览器:chrome,firefox. safari则没有问题。

只需要一段js代码就可以获取我们的真实IP。一旦被想时时监控别人的人知道并使用此方法钓鱼,便可直接获得原始IP。这简直太恐怖了。

看来以后如果重装系统,第一件事儿把cnnic证书删除后,第二件事儿就是禁用WebRTC.

有一个插件可以方便的禁用WebRTC, 插件下载

Firefox可在浏览器上输入:about:config。之后搜索:media.peerconnection.enabled。找到它后双击,将其改成 false 即可。

原理可以参考一下这里: https://github.com/diafygi/webrtc-ips

或者直接把下面这段代码放在chrome的console里运行一下,就知道自己的真实IP了。


//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 = /([0-9]{1,3}(.[0-9]{1,3}){3})/ 
var ip_addr = ip_regex.exec(ice.candidate.candidate)[1];

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

ip_dups[ip_addr] = 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(){});

}, function(){}); 
}

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

from:http://ju.outofmemory.cn/entry/333116

原文地址:https://www.cnblogs.com/xuan52rock/p/11249083.html