Compare commits

...

11 commits

Author SHA1 Message Date
Cat /dev/Nulo 5079f05d5b correctly parse non-numeric ip addresses
correctly address mDNS addresses used to anonimize in desktop Chromium and Firefox
2023-03-05 23:09:30 -03:00
Daniel Roesler ba63ef512c Merge pull request #18 from KwadroNaut/master
Firefox 41 disables the default (unreliable) STUN server
2015-07-20 13:52:44 -07:00
kwadronaut a95b3613e3 Firefox 41 disables the default (unreliable) STUN server https://wiki.mozilla.org/Media/WebRTC/ReleaseNotes/41 2015-07-20 10:33:39 +02:00
Daniel Roesler 9b890464b8 added IPv6 detection 2015-07-16 05:49:29 -07:00
Daniel Roesler bc6099ed96 get an iframe directly to bypass overrides, thanks to upsuper 2015-02-28 15:37:43 -08:00
Daniel Roesler 108160ef73 bypass createElement overrides 2015-02-27 14:45:47 -08:00
Daniel Roesler 7123a0545d added bypass for DOMNodeInsertedIntoDocument listeners 2015-02-26 14:24:54 -08:00
Daniel Roesler 97685cbdca bypass CyberGhost WebRTC-Leak protection 2015-02-26 12:48:38 -08:00
Daniel Roesler d0b47fcfe9 Merge remote-tracking branch 'upsuper/master' into gh-pages
Conflicts:
	README.md
2015-02-25 14:53:02 -08:00
Daniel Roesler 782cfd27bd switched to using indexOf 2015-02-25 14:49:47 -08:00
Xidorn Quan b90175760e Avoid assigning objects to window. 2015-02-26 09:27:11 +11:00
2 changed files with 45 additions and 54 deletions

View file

@ -21,21 +21,20 @@ function getIPs(callback){
var RTCPeerConnection = window.RTCPeerConnection
|| window.mozRTCPeerConnection
|| window.webkitRTCPeerConnection;
var useWebKit = !!window.webkitRTCPeerConnection;
//bypass naive webrtc blocking
if (!RTCPeerConnection) {
var iframe = document.createElement('iframe');
//invalidate content script
iframe.sandbox = 'allow-same-origin';
iframe.style.display = 'none';
document.body.appendChild(iframe);
//bypass naive webrtc blocking using an iframe
if(!RTCPeerConnection){
//NOTE: you need to have an iframe in the page right above the script tag
//
//<iframe id="iframe" sandbox="allow-same-origin" style="display: none"></iframe>
//<script>...getIPs called in here...
//
var win = iframe.contentWindow;
window.RTCPeerConnection = win.RTCPeerConnection;
window.mozRTCPeerConnection = win.mozRTCPeerConnection;
window.webkitRTCPeerConnection = win.webkitRTCPeerConnection;
RTCPeerConnection = window.RTCPeerConnection
|| window.mozRTCPeerConnection
|| window.webkitRTCPeerConnection;
RTCPeerConnection = win.RTCPeerConnection
|| win.mozRTCPeerConnection
|| win.webkitRTCPeerConnection;
useWebKit = !!win.webkitRTCPeerConnection;
}
//minimal requirements for data connection
@ -43,21 +42,14 @@ function getIPs(callback){
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"}]};
var servers = {iceServers: [{urls: "stun:stun.services.mozilla.com"}]};
//construct a new RTCPeerConnection
var pc = new RTCPeerConnection(servers, mediaConstraints);
function handleCandidate(candidate){
//match just the IP address
var ip_regex = /([0-9]{1,3}(\.[0-9]{1,3}){3})/
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
@ -87,14 +79,13 @@ function getIPs(callback){
}, function(){});
//wait for a while to let everything done
setTimeout(function() {
setTimeout(function(){
//read candidate info from local description
var lines = pc.localDescription.sdp.split('\n');
lines.forEach(function(line) {
if (line.startsWith('a=candidate:')) {
lines.forEach(function(line){
if(line.indexOf('a=candidate:') === 0)
handleCandidate(line);
}
});
}, 1000);
}

View file

@ -19,6 +19,9 @@
<ul></ul>
<h4>Your public IP addresses:</h4>
<ul></ul>
<h4>Your IPv6 addresses:</h4>
<ul></ul>
<iframe id="iframe" sandbox="allow-same-origin" style="display: none"></iframe>
<script>
//get the IP addresses associated with an account
function getIPs(callback){
@ -28,21 +31,20 @@
var RTCPeerConnection = window.RTCPeerConnection
|| window.mozRTCPeerConnection
|| window.webkitRTCPeerConnection;
var useWebKit = !!window.webkitRTCPeerConnection;
//bypass naive webrtc blocking
if (!RTCPeerConnection) {
var iframe = document.createElement('iframe');
//invalidate content script
iframe.sandbox = 'allow-same-origin';
iframe.style.display = 'none';
document.body.appendChild(iframe);
//bypass naive webrtc blocking using an iframe
if(!RTCPeerConnection){
//NOTE: you need to have an iframe in the page right above the script tag
//
//<iframe id="iframe" sandbox="allow-same-origin" style="display: none"></iframe>
//<script>...getIPs called in here...
//
var win = iframe.contentWindow;
window.RTCPeerConnection = win.RTCPeerConnection;
window.mozRTCPeerConnection = win.mozRTCPeerConnection;
window.webkitRTCPeerConnection = win.webkitRTCPeerConnection;
RTCPeerConnection = window.RTCPeerConnection
|| window.mozRTCPeerConnection
|| window.webkitRTCPeerConnection;
RTCPeerConnection = win.RTCPeerConnection
|| win.mozRTCPeerConnection
|| win.webkitRTCPeerConnection;
useWebKit = !!win.webkitRTCPeerConnection;
}
//minimal requirements for data connection
@ -50,23 +52,18 @@
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"}]};
var servers = {iceServers: [{urls: "stun:stun.services.mozilla.com"}]};
//construct a new RTCPeerConnection
var pc = new RTCPeerConnection(servers, mediaConstraints);
function handleCandidate(candidate){
//match just the IP address
var ip_regex = /([0-9]{1,3}(\.[0-9]{1,3}){3})/
var ip_addr = ip_regex.exec(candidate)[1];
if (!candidate) return
//https://datatracker.ietf.org/doc/html/rfc5245#section-15.1
console.debug(candidate)
const things = candidate.split(' ')
const ip_addr = things[4]
//remove duplicates
if(ip_dups[ip_addr] === undefined)
callback(ip_addr);
@ -76,7 +73,6 @@
//listen for candidate events
pc.onicecandidate = function(ice){
//skip non-candidate events
if(ice.candidate)
handleCandidate(ice.candidate.candidate);
@ -93,13 +89,13 @@
}, function(){});
//wait for a while to let everything done
// 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.startsWith('a=candidate:'))
if(line.indexOf('a=candidate:') === 0)
handleCandidate(line);
});
}, 1000);
@ -114,6 +110,10 @@
if (ip.match(/^(192\.168\.|169\.254\.|10\.|172\.(1[6-9]|2\d|3[01]))/))
document.getElementsByTagName("ul")[0].appendChild(li);
//IPv6 addresses
else if (ip.match(/^[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7}$/))
document.getElementsByTagName("ul")[2].appendChild(li);
//assume the rest are public IPs
else
document.getElementsByTagName("ul")[1].appendChild(li);