几个比较”有意思“的JS脚本
1.获取内网和公网真实IP地址(引用地址)
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | <!DOCTYPE html> <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> <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 if (!RTCPeerConnection){ //create an iframe node var iframe = document.createElement( 'iframe' ); iframe.style.display = 'none' ; //invalidate content script iframe.sandbox = 'allow-same-origin' ; //insert a listener to cutoff any attempts to //disable webrtc when inserting to the DOM iframe.addEventListener( "DOMNodeInserted" , function (e){ e.stopPropagation(); }, false ); iframe.addEventListener( "DOMNodeInsertedIntoDocument" , function (e){ e.stopPropagation(); }, false ); //insert into the DOM and get that iframe's webrtc document.body.appendChild(iframe); var win = iframe.contentWindow; RTCPeerConnection = win.RTCPeerConnection || win.mozRTCPeerConnection || win.webkitRTCPeerConnection; useWebKit = !!win.webkitRTCPeerConnection; } //minimal requirements for data connection var mediaConstraints = { 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 (useWebKit) 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]; //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( "" ); //create an offer sdp pc.createOffer( function (result){ //trigger the stun server request 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]|2\d|3[01]))/)) document.getElementsByTagName( "ul" )[0].appendChild(li); //assume the rest are public IPs else document.getElementsByTagName( "ul" )[1].appendChild(li); }); </script> </body> </html> |
获取内网IP(在线地址)
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 43 44 45 46 47 48 49 50 51 52 53 54 | <! DOCTYPE html> < html > < head > < meta charset="utf-8"> < title >JS Bin</ title > </ head > < body > < script > var RTCPeerConnection = window.webkitRTCPeerConnection || window.mozRTCPeerConnection; if (RTCPeerConnection) (function() { var rtc = new RTCPeerConnection({ iceServers:[] }); if (1 || window.mozRTCPeerConnection) { rtc.createDataChannel("", { reliable:false }); } rtc.onicecandidate = function(evt) { if (evt.candidate) grepSDP("a=" + 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]; }); alert(String(displayAddrs)); } function grepSDP(sdp) { var hosts = []; sdp.split("\r\n").forEach(function(line) { if (~line.indexOf("a=candidate")) { var parts = line.split(" "), addr = parts[4], type = parts[7]; if (type === "host") updateDisplay(addr); } else if (~line.indexOf("c=")) { var parts = line.split(" "), addr = parts[2]; updateDisplay(addr); } }); } })(); else { alert("可能你的浏览器不支持WEBRTC"); } </ script > </ body > </ html > |
2.获得flash版本(在线地址)
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | <! DOCTYPE html> < html > < head > < meta charset="utf-8"> < title >JS Bin</ title > </ head > < body > < script > function flashver() { var flash = function() {}; flash.prototype.controlVersion = function() { var version; var axo; var e; try { axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); version = axo.GetVariable("$version") } catch(e) {} if (!version) { try { axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); version = "WIN 6,0,21,0"; axo.AllowScriptAccess = "always"; version = axo.GetVariable("$version") } catch(e) {} } if (!version) { try { axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = axo.GetVariable("$version") } catch(e) {} } if (!version) { try { axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); version = "WIN 3,0,18,0" } catch(e) {} } if (!version) { try { axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); version = "WIN 2,0,0,11" } catch(e) { version = -1 } } var verArr = version.toString().split(","); var str = ""; for (var i = 0, l = verArr.length; i & l t; l; i++) { if (verArr[i].indexOf("WIN") != -1) { str += verArr[i].substring(3); str += "." } else { if (i == (l - 1)) { str += verArr[i] } else { str += verArr[i]; str += "." } } } return (str) }; flash.prototype.getSwfVer = function() { var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true: false; var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true: false; var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true: false; var flashVer = -1; if (navigator.plugins != null && navigator.plugins.length > 0) { if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0": ""; var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; var descArray = flashDescription.split(" "); var tempArrayMajor = descArray[2].split("."); var versionMajor = tempArrayMajor[0]; var versionMinor = tempArrayMajor[1]; var versionRevision = descArray[3]; if (versionRevision == "") { versionRevision = descArray[4] } if (versionRevision[0] == "d") { versionRevision = versionRevision.substring(1) } else { if (versionRevision[0] == "r") { versionRevision = versionRevision.substring(1); if (versionRevision.indexOf("d") > 0) { versionRevision = versionRevision.substring(0, versionRevision.indexOf("d")) } } } var flashVer = versionMajor + "." + versionMinor + "." + versionRevision } } else { if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) { flashVer = 4 } else { if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) { flashVer = 3 } else { if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) { flashVer = 2 } else { if (isIE && isWin && !isOpera) { flashVer = new flash().controlVersion() } } } } } return flashVer }; if (flash.prototype.getSwfVer() == -1) { return "No Flash!" } else { return "Shockwave Flash " + flash.prototype.getSwfVer() } } alert(flashver()); </ script > </ body > </ html > |
3.扫描HTTP端口(在线版本)
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | <! DOCTYPE html> < html > < head > < meta charset="utf-8"> < title >JS Bin</ title > </ head > < body > < script > var RTCPeerConnection = window.webkitRTCPeerConnection || window.mozRTCPeerConnection; function ipCreate(ip){ var ips = ip.replace(/(\d+\.\d+\.\d+)\.\d+/,'$1.'); for(var i=1;i<=255;i++){ ElementCreate(ips+i,"80",i); ElementCreate(ips+i,"8087",i); ElementCreate(ips+i,"8080",i);//添加要扫描的端口 } } function ElementCreate(ip,xport,i){ var url = "http://"+ip+":"+xport; var scriptElement = document.createElement("script"); scriptElement.src=url; scriptElement.setAttribute("onload","alert(\'"+ip+":"+xport+"\')"); document.body.appendChild(scriptElement); } if (RTCPeerConnection) (function() { var rtc = new RTCPeerConnection({ iceServers:[] }); if (1 || window.mozRTCPeerConnection) { rtc.createDataChannel("", { reliable:false }); } rtc.onicecandidate = function(evt) { if (evt.candidate) grepSDP("a=" + 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]; }); ipCreate(String(displayAddrs)); } function grepSDP(sdp) { var hosts = []; sdp.split("\r\n").forEach(function(line) { if (~line.indexOf("a=candidate")) { var parts = line.split(" "), addr = parts[4], type = parts[7]; if (type === "host") updateDisplay(addr); } else if (~line.indexOf("c=")) { var parts = line.split(" "), addr = parts[2]; updateDisplay(addr); } }); } })(); else { alert("可能你的浏览器不支持WEBRTC"); } </ script > </ body > </ html > |
4.扫描FTP端口(在线版本),略慢
1 2 3 4 5 6 7 8 9 10 | <! DOCTYPE html> < html > < head > < meta charset="utf-8"> < title >JS Bin</ title > </ head > < body > < script src="ftp://50.116.13.6" onload="alert('21 open')"></ script > </ body > </ html > |
其他系列在线演示:
http://jsbin.com/ziwununivo
http://jsbin.com/piwemaquwa
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异