-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWebRTC_Leak_PoC.html
42 lines (36 loc) · 1.61 KB
/
WebRTC_Leak_PoC.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<body>
<p>Click to test for WebRTC leaks:</p>
<button id="test-button">WebRTC Leak Test</button>
<div id="ip-display"></div>
<script>
document.getElementById('test-button').addEventListener('click', () => {
const ipDisplay = document.getElementById('ip-display');
ipDisplay.innerHTML = '';
const discoverIPs = (onNewIP) => {
const peerConnection = new RTCPeerConnection({ iceServers: [{ urls: "stun:stun.l.google.com:19302" }] });
const ipAddressPattern = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g;
const uniqueIPs = new Set();
peerConnection.createDataChannel("");
peerConnection.createOffer()
.then(offer => peerConnection.setLocalDescription(offer))
peerConnection.onicecandidate = event => {
if (event.candidate) {
event.candidate.candidate.match(ipAddressPattern)?.forEach(ip => {
if (!uniqueIPs.has(ip)) {
uniqueIPs.add(ip);
onNewIP(ip);
}
});
}
};
};
discoverIPs(ip => {
const ipElement = document.createElement('div');
ipElement.textContent = ip; // Set the text content to the IP address
ipDisplay.appendChild(ipElement); // Add the new element to the container
});
});
</script>
</body>
</html>