js获得外网内网IP(杂项拓展)

利用WebRtc ( Firefox 、 Chrome )在支持Rtc的浏览器漏洞可以获取用户的真实内外网IP

想写写一个聊天室的时候想要查看下用户IP,加这么一个功能,然后网上都是写好的接口,就寻思着有没有原生JS能获取到的,结果查找到了个漏洞。
urls: “stun:stun.l.google.com:19302” 这是可以访问到外网IP的 stun。
网上的demo用的是 stun.services.mozilla.com 毫无疑问的翻车 可能地址被墙了。

不信邪的我还真的找到了,但是处于安全性问题JS应该是没有B/S相关的支持直接查询外网的IP,可能需要后端的支持,
翻阅了很多大佬的博客和文章这个BUG出现在09年以前貌似 有点厉害了 且行且珍惜。


<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
head>
<body>
<h4>
    Demo for:
    <a href="https://github.com/diafygi/webrtc-ips">
        https://github.com/diafygi/webrtc-ips
    a>
h4>
<p>
    This demo secretly makes requests to STUN servers that can log your
    request. These requests do not show up in developer consoles and
    cannot be blocked by browser plugins (AdBlock, Ghostery, etc.).
p>
<h4>Your local IP addresses:h4>
<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){
        var ip_dups = {};
        //compatibility for firefox and chrome
        var RTCPeerConnection = window.RTCPeerConnection
            || window.mozRTCPeerConnection
            || window.webkitRTCPeerConnection;
        var useWebKit = !!window.webkitRTCPeerConnection;
        //bypass naive webrtc blocking using an iframe
        if(!RTCPeerConnection){
            //NOTE: you need to have an iframe in the page right above the script tag
            //
            //
            //
                    
                    

你可能感兴趣的:(JS,WebRtc,杂货铺)