自从之前被腾讯封杀我的笔记本,换ip也不行,估计是拿到了我的mac地址。找了一下通过js是可以获取mac地址的
js也可以获取ip地址,不过要基于ie浏览器的Activex才行,目测chrome不行。估计腾讯应该通过浏览器调用的本地的qq的文件了。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JS获取客户端MAC地址</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<style type="text/css">
</style>
<script event="OnObjectReady(objObject,objAsyncContext)" for="foo">
if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined" && objObject.IPEnabled == true) {
if(objObject.MACAddress != null && objObject.MACAddress != "undefined" && objObject.DNSServerSearchOrder!=null)
MACAddr = objObject.MACAddress;
if(objObject.IPEnabled && objObject.IPAddress(0) != null && objObject.IPAddress(0) != "undefined" && objObject.DNSServerSearchOrder!=null)
IPAddr = objObject.IPAddress(0);
if(objObject.DNSHostName != null && objObject.DNSHostName != "undefined")
sDNSName = objObject.DNSHostName;
}
</script>
<script type="text/javascript">
var MACAddr ;
var IPAddr ;
var DomainAddr;
var sDNSName;
function init() {
var service = locator.ConnectServer();
service.Security_.ImpersonationLevel=3;
service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration');
}
function getMac() {
document.getElementById('txtMac').value = unescape(MACAddr);
}
function getIp()
{
document.getElementById('txtIp').value = unescape(IPAddr);
}
</script>
</head>
<body onload="init()">
<object id="locator" classid="CLSID:76A64158-CB41-11D1-8B02-00600806D9B6" VIEWASTEXT></object>
<object id="foo" classid="CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223"></object>
<input type="text" id="txtMac" />
<input type="button" id="btn" value="获取Mac地址" onclick="getMac();" />
<input type="text" id="txtIp" />
<input type="button" id="btn" value="获取ip地址" onclick="getIp();" />
</body>
</html>
如何验证获取的ip和mac地址是否是正确?
1、cmd ipconfig /all
2、打开网络与共享中心,本地链接,详细信息
来源:oschina
链接:https://my.oschina.net/u/2326984/blog/599924