WebRTC红蓝对抗(WebRTC漏洞检测)

Part1 基本概念

0x01:什么是WebRTC?

WebRTC(网页即时通信,Web Real-Time Communication) 它支持在浏览器内进行实时语音或视频对话,而无需添加额外的浏览器扩展。包括 Chrome、Firefox、Opera、Safari。并且在移动端也有支持。WebRTC 漏洞会导致即使你用了代理仍然会暴露自己的真实 IP 地址。

0x02:WebRTC 漏洞原理

WebRTC 这个漏洞是在 2015 年初被发现的,至今仍然没有被修复并且往往被忽视,该漏洞至今仍影响大部分的浏览器。

WebRTC并不会走代理,因为其设计之初就是为了点对点通信用来方便流媒体更流畅的传输,同样这个特性会让使用代理的人把自己的真实ip暴露在网站服务端,并且利用的唯一条件就是浏览器支持WebRTC 和 JavaScript。

Part2 测试环节

0x03:本地Demo测试

Demo测试代码:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
Remote Addr: <?=$_SERVER['REMOTE_ADDR']?>
<hr>
<h3>WebRTC</h3>
<h4>Your local IP addresses:</h4>
<ul id="localip"></ul>
<h4>Your public IP addresses:</h4>
<ul id="publicip"></ul>
<h4>Your IPv6 addresses:</h4>
<ul id="ipv6"></ul>
<iframe id="rtc_iframe" sandbox="allow-same-origin" style="display: none"></iframe>
<script>
//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.msRTCPeerConnection
|| window.webkitRTCPeerConnection;
var useWebKit = !!window.webkitRTCPeerConnection;
//bypass naive webrtc blocking using an iframe
if(!RTCPeerConnection){
var win = document.getElementById("rtc_iframe").contentWindow;
RTCPeerConnection = win.RTCPeerConnection
|| win.mozRTCPeerConnection
|| win.msRTCPeerConnection
|| win.webkitRTCPeerConnection;
useWebKit = !!win.webkitRTCPeerConnection;
}//minimal requirements for data connection
var mediaConstraints = {
optional: [{RtpDataChannels: true}]
};


var servers = {
iceServers: [
{urls: [
'stun:stun.l.google.com:19302?transport=udp',
'stun:stun1.l.google.com:19302?transport=udp',
'stun:stun2.l.google.com:19302?transport=udp',
'stun:stun3.l.google.com:19302?transport=udp',
'stun:stun4.l.google.com:19302?transport=udp',
"stun:stun.ekiga.net?transport=udp",
"stun:stun.ideasip.com?transport=udp",
"stun:stun.rixtelecom.se?transport=udp",
"stun:stun.schlund.de?transport=udp",
"stun:stun.stunprotocol.org:3478?transport=udp",
"stun:stun.voiparound.com?transport=udp",
"stun:stun.voipbuster.com?transport=udp",
"stun:stun.voipstunt.com?transport=udp",
"stun:stun.voxgratia.org?transport=udp"
]
}]
};
//construct a new RTCPeerConnection
var pc;
try {
pc = new RTCPeerConnection(servers, mediaConstraints);
}catch (e) {
return
}function handleCandidate(candidate){
//match just the IP address
var ip_regex = /([0-9]{1,3}(.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/
var ip_addr = ip_regex.exec(candidate)[1];
//remove duplicates
if(ip_dups[ip_addr] === undefined)
callback(ip_addr);
ip_dups[ip_addr] = true;
}//listen for candidate events
pc.onicecandidate = function(ice){
//skip non-candidate events
if(ice.candidate)
handleCandidate(ice.candidate.candidate);
};


//create a bogus data channel
pc.createDataChannel("bl");
//create an offer sdp
try {
pc.createOffer().then(function(result) {
pc.setLocalDescription(result);
});
}catch (e) {
pc.createOffer().then(function(result) {
pc.setLocalDescription(result, function(){}, function(){});
}, function() {});
}//wait for a while to let everything done
setTimeout(function(){
//read candidate info from local description
var lines = pc.localDescription.sdp.split('n');


lines.forEach(function(line){
if(line.indexOf('a=candidate:') === 0)
handleCandidate(line);
});
}, 1000);
}//insert IP addresses into the page
getIPs(function(ip){
var li = document.createElement("li");
li.textContent = ip;
//local IPs
if (ip.match(/^(192.168.|169.254.|10.|172.(1[6-9]|2d|3[01]))/))
document.getElementById("localip").appendChild(li);
//IPv6 addresses
else if (ip.match(/^[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7}$/))
document.getElementById("ipv6").appendChild(li);
//assume the rest are public IPs
else
document.getElementById("publicip").appendChild(li);
});
</script>
</body>
</html>

本地搭建测试一下发现,已经使用代理访问,但仍然被get到真实IP

图片
在线检测地址:https://ip.voidsec.com/

同样可以检测到自己的真实ip

图片

Part3 部分应用场景的防范措施

0x04:WebRTC 漏洞防范措施

如果不想自己的真实IP地址泄漏,可以通过禁用 WebRTC 来防止真实 IP 地址泄漏。

Chrome 安装扩展禁用:

安装「WebRTC Leak Prevent」扩展插件

图片

将「IP handling policy」选项设置为「Disable non-proxied UDP (force proxy)」

图片

设置完成后重启插件即可

Firefox 修改配置禁用:

在浏览器地址栏输入「about:config」回车

图片

搜索「media.peerconnection.enabled」字段

图片

双击「media.peerconnection.enabled」首选项,使其值变为「false」

图片
图片

红蓝对抗下的应用场景:

红队:

将浏览器禁用WebRTC功能;

改用高匿名的全局代理;

禁掉了WebRTC后,测试一下再进行打点;

蓝队:

对重点网页进行嵌入;

对出现概率高的页面进行嵌入,如404页面;

对蜜罐页面嵌入;

Part4 更多在线隐私检测地址

检测 IP 泄漏:https://ipleak.net
检测 WebRTC 泄漏:https://diafygi.github.io/webrtc-ips/
检测 WebRTC 泄漏:https://www.expressvpn.com/webrtc-leak-test
检测 WebRTC 泄漏:https://www.privacytools.io/webrtc.html
设备信息检测:https://do-know.com/privacy-test.html
WebRTC 漏洞检测:https://www.perfect-privacy.com/webrtc-leaktest/
浏览器泄漏检测:https://browserleaks.com/webrtc

来源:公众号——“D&X 安全实验室”,专注渗透测试技术和全球最新网络攻击技术

版权声明:本文内容转自互联网,本文观点仅代表作者本人。本站仅提供信息存储空间服务,所有权归原作者所有。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至1393616908@qq.com 举报,一经查实,本站将立刻删除。

(0)

相关推荐

发表回复

登录后才能评论