怎樣獲取客戶端ip及mac地址?

来源:互联网 发布:热血江湖传进阶数据 编辑:程序博客网 时间:2024/05/17 02:50

取客戶端ip  

userip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
 If userip = "" Then userip = Request.ServerVariables("REMOTE_ADDR")

 hostname=Request.ServerVariables("HTTP_HOST")

取mac地址
 mac=GetMACAddress(userip)

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

原创粉丝点击