首页 技术 正文
技术 2022年11月13日
0 收藏 352 点赞 4,413 浏览 8656 个字

1.获取内网和公网真实IP地址(引用地址

<!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" rel="external nofollow" >
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(在线地址

<!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版本(在线地址

几个比较”有意思“的JS脚本

<!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; 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端口(在线版本

几个比较”有意思“的JS脚本

<!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端口(在线版本略慢

几个比较”有意思“的JS脚本

<!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

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,086
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,561
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,410
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,183
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,820
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,903