王盼盼波浪理论 视频:怎样通过Web方式获得对方的网卡MAC地址?

来源:百度文库 编辑:高校问答 时间:2024/05/09 05:11:28
我正在开发一个B/S版的营运系统,系统要求当用户通过浏览器登陆系统时,能得到用户电脑网卡的MAC地址,不知道如何能够实现
该系统是用VB.NET写的一个ASP.NET程序

<%

strIP = Request.ServerVariables("REMOTE_ADDR")

strMac = GetMACAddress(strIP)

strHost = Request.ServerVariables("REMOTE_HOST")

Function GetMACAddress(strIP)

Set net = Server.CreateObject("wscript.network")

Set sh = Server.CreateObject("wscript.shell")

sh.run "%comspec% /c nbtstat -A " & strIP & " > c:" & strIP & ".txt",0,true

Set sh = nothing

Set fso = createobject("scripting.filesystemobject")

Set ts = fso.opentextfile("c:" & strIP & ".txt")

macaddress = null

Do While Not ts.AtEndOfStream

data = ucase(trim(ts.readline))

If instr(data,"MAC ADDRESS") Then

macaddress = trim(split(data,"=")(1))

Exit Do

End If

loop

ts.close

Set ts = nothing

fso.deletefile "c:" & strIP & ".txt"

Set fso = nothing

GetMACAddress = macaddress

End Function

%>

<HTML>

<HEAD>

<TITLE>Say Hello To the MAC MAN</TITLE>

</HEAD>

<BODY>

<%Response.Write("Your IP is : " & strIP & "<BR>" & vbcrlf)%>

<%Response.Write("Your MAC is : " & strMac & vbcrlf)%>

</BODY>

</HTML>

后记:此程序中需要USER_****用户有C盘的写入权限,也可以将文中的“C:”改为有写权限的驱动器(或目录)也可。