Google Chrome gets windows MAC address through extension

introduce

Chrome get mac address plugin

Software Architecture

Refer to the chrome plug-in development specification

Installation Tutorial

Copy the root directory of the plug-in to any disk directory. Once selected, do not move it. The directory name does not contain spaces. Modify the matches property in manifest.json to install the chrome browser for the domain name of the website to be enabled, open the browser => more tools => extensions => developer mode => load the decompressed extension => select the root directory of the plug-in to
complete
.
Check the plugin id and make sure that the chrome-extension id in the com.yd.macaddr.nativemessage.json file is consistent. Turn off developer mode.
Click to run host-install.bat and the installation is successful. (Run host-uninstall.bat to download)
Instructions for use

After the above steps are completed, the mac address can be obtained from the browser localstorage in the project code. Example: var mac = localStorage.getItem("mac")
 

https://gitee.com/xcj0654335/macaddr-chrome-extension

https://blog.csdn.net/zhangjs712/article/details/50913114?utm_medium=distribute.pc_relevant_download.none-task-blog-blogcommendfrombaidu-3.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-blogcommendfrombaidu-3.nonecas

https://blog.csdn.net/weixin_33840661/article/details/87948213?utm_medium=distribute.pc_relevant_download.none-task-blog-blogcommendfrombaidu-2.nonecase&depth_1-utm_source=distribute.pc_relevant_download.none-task-blog-blogcommendfrombaidu-2.nonecas

chrome extension production steps

https://www.cnblogs.com/liuxianan/p/chrome-plugin-develop.html

ie get mac address
 

<HTML>
<HEAD>
<TITLE>WMI Scripting HTML</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<SCRIPT language=JScript event="OnCompleted(hResult,pErrorObject, pAsyncContext)" for=foo>
 document.forms[0].txtMACAddr.value=unescape(MACAddr);
 document.forms[0].txtIPAddr.value=unescape(IPAddr);
 document.forms[0].txtDNSName.value=unescape(sDNSName);
 //document.formbar.submit();
  </SCRIPT>
 
<SCRIPT language=JScript event=OnObjectReady(objObject,objAsyncContext) for=foo>
   if(objObject.IPEnabled != null && objObject.IPEnabled != "undefined" && objObject.IPEnabled == true)
   {
    if(objObject.MACAddress != null && objObject.MACAddress != "undefined")
    MACAddr = objObject.MACAddress;
    if(objObject.IPEnabled && objObject.IPAddress(0) != null && objObject.IPAddress(0) != "undefined")
    IPAddr = objObject.IPAddress(0);
    if(objObject.DNSHostName != null && objObject.DNSHostName != "undefined")
    sDNSName = objObject.DNSHostName;
    }
  </SCRIPT>
 
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY>
<OBJECT id=locator classid=CLSID:76A64158-CB41-11D1-8B02-00600806D9B6 VIEWASTEXT></OBJECT>
<OBJECT id=foo classid=CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223></OBJECT>
<SCRIPT language=JScript>
   var service = locator.ConnectServer();
   var MACAddr ;
   var IPAddr ;
   var DomainAddr;
   var sDNSName;
   service.Security_.ImpersonationLevel=3;
   service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration');
   </SCRIPT>
 
<FORM id="formfoo" name="formbar" action="index.do" method="post">
<INPUT value="00-11-11-B4-52-EF"   name="txtMACAddr"> 
<INPUT value="210.42.38.50"  name="txtIPAddr">
 <INPUT value="zhupan" name="txtDNSName">
 </FORM>
</BODY>
</HTML>

2

function getMac() {
    var locator = new ActiveXObject("WbemScripting.SWbemLocator"); // 创建ActiveXObject对象
    var service = locator.ConnectServer("."); //连接本机服务器
    var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration Where IPEnabled = TRUE"); // 查询地址适配器信息
    var e = new Enumerator(properties);
    var macs = [];
    for (; !e.atEnd(); e.moveNext()) {
        macs.push(e.item().MACAddress);
    }
    alert(macs.join(","));
   // return macs.join(","); // 用逗号拼接mac数组
}

3

 <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
   <title>JS获取客户端MAC地址</title>
   <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
   <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>```

Guess you like

Origin blog.csdn.net/qq_22905801/article/details/129536745