怎样禁用浏览器的WebRTC?这东西居然能读取本地IP!!

2014-01-23 20:54:21 +08:00
 the13matrix
可以直接从本地读取IP。和ipconfig /all看到的IP一样。
如果电脑直接播号上网,则获取到的就是公网IP。如果是家庭、学校、公司的内网,获取到的就是内网IP。如果系统里有虚拟网卡,虚拟网卡IP也加入列表。
测试代码:(对Chrome和Firefox有效)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>获取内网IP</title>
</head>
<body>
您的内网IP:
<span id="list"></span>
<script>
// NOTE: window.RTCPeerConnection is "not a constructor" in FF22/23
var RTCPeerConnection = /*window.RTCPeerConnection ||*/ window.webkitRTCPeerConnection || window.mozRTCPeerConnection;
if (RTCPeerConnection) (function () {
var rtc = new RTCPeerConnection({iceServers:[]});
if (window.mozRTCPeerConnection) { // FF needs a channel/stream to proceed
rtc.createDataChannel('', {reliable:false});
};
rtc.onicecandidate = function (evt) {
if (evt.candidate) grepSDP(evt.candidate.candidate);
};
rtc.createOffer(function (offerDesc) {
grepSDP(offerDesc.sdp);
rtc.setLocalDescription(offerDesc);
}, function (e) { console.warn("offer failed", e); });
var addrs = Object.create(null);
addrs["0.0.0.0"] = false;
function updateDisplay(newAddr) {
if (newAddr in addrs) return;
else addrs[newAddr] = true;
var displayAddrs = Object.keys(addrs).filter(function (k) { return addrs[k]; });
document.getElementById('list').innerHTML = displayAddrs.join(" or perhaps ") || "n/a";
}
function grepSDP(sdp) {
var hosts = [];
sdp.split('\r\n').forEach(function (line) { // c.f.http://tools.ietf.org/html/rfc4566#page-39
if (~line.indexOf("a=candidate")) { //http://tools.ietf.org/html/rfc4566#section-5.13
var parts = line.split(' '), //http://tools.ietf.org/html/rfc5245#section-15.1
addr = parts[4],
type = parts[7];
if (type === 'host') updateDisplay(addr);
} else if (~line.indexOf("c=")) { //http://tools.ietf.org/html/rfc4566#section-5.7
var parts = line.split(' '),
addr = parts[2];
updateDisplay(addr);
}
});
}
})(); else {
document.getElementById('list').innerHTML = "<code>ifconfig | grep inet | grep -v inet6 | cut -d\" \" -f2 | tail -n1</code>";
document.getElementById('list').nextSibling.textContent = "In Chrome and Firefox your IP should display automatically, by the power of WebRTCskull.";
}
</script>
</body>
</html>
建网站的朋友,可以用这个判断访客是内网用户还是公网。并且获取访客内网IP。
不管你用了多少层匿名代理/VPN,这段代码都能直接提取本地IP。然后一个异步请求,就可以被服务端提取。浏览器无任何安全提示。
28745 次点击
所在节点    WebRTC
17 条回复
ihacku
2014-01-23 22:20:54 +08:00
chrome://flags/ 试试关掉里面相关的flag试试?
notedit
2014-01-23 22:29:02 +08:00
webrtc 启用的时候都要被授权 你可以点击deny
the13matrix
2014-01-23 22:29:25 +08:00
@ihacku 里面有停用webrtc,但显示:抱歉,此实验无法在您的平台上进行。
只有android平台下的chrome支持关掉webrtc?
the13matrix
2014-01-23 22:34:52 +08:00
@notedit 上面那段读取本地IP的代码不用授权。你可以测试一下。
airyland
2014-01-23 22:49:54 +08:00
感谢楼主分享,亲测有效。原来可以这样获取。。
initialdp
2014-01-23 23:01:36 +08:00
不奇怪啊,webrtc本来就是用于通信的,肯定需要拿到这些地址信息才行。
switch
2014-01-23 23:16:56 +08:00
可以使用 GM 来重写 RTCPeerConnection 构造函数,使其失效。
est
2014-01-23 23:23:28 +08:00
chrome还有个bug就是可以后台麦克风录音
xvfeng
2014-01-23 23:46:07 +08:00
webrtc本身没有连接功能.需要先通过一个signal的服务器来建立连接才行. 正常情况下根本不可能出现安全问题. 楼主禁用webrtc是要怎样...
the13matrix
2014-01-24 00:02:52 +08:00
@xvfeng 正常情况下,浏览器不该有读取网卡IP的权限。
yfdyh000
2014-01-24 00:50:21 +08:00
确认是不经授权的泄露。
最初披露者像是 http://net.ipcalf.com/ ,用这个地址能搜到相关的讨论。
Firefox 用 media.peerconnection.enabled 可禁用功能避免泄露,Tor Browser 就已默认禁用。
Chrome 的禁用方法没找到。
582033
2014-01-24 09:36:06 +08:00
@the13matrix 这不算什么吧,相比chrome的另一大功能(话筒处于随时监听状态)小巫见大巫了啊。
est
2014-01-24 09:36:35 +08:00
@yfdyh000

看了下

https://2x.io/read/security-by-obscurity

把我的桥接IP都识别出来了。厉害。
DearMark
2014-01-24 11:21:36 +08:00
我的firefox无法获取ip,chrome可以
bigbee
2014-08-11 12:29:22 +08:00
我的firefox、chrome都可以
ForMoom
2015-02-02 11:42:29 +08:00
@yfdyh000 听说Chrome 浏览器可以安装 WebRTC block 或 ScriptSafe 插件,
Chrome 浏览器ScriptSafe扩展的地址:
https://chrome.google.com/webstore/search/ScriptSafe
impig33
2016-05-13 10:29:44 +08:00
来个详细的说明
firefox 输入 about:config 将 media.peerconnection.enabled 设为 false
chrome 安装 webRTC blocker 禁用

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/98147

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX