• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

获得客房端的MAC(Media Access Control)地址

发布: 2007-7-13 21:20 | 作者: 佚名    | 来源: 网络转载     | 查看: 11次 | 进入软件测试论坛讨论

领测软件测试网
     Get the clients MAC(Media Access Control) address, a hardware address that uniquely identifies each
node of a network. Works great on LAN's. Firewalls and Proxy's will be an issue depending what side of
them you're coding for.


  
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!



    '**************************************
    ' for :MAC address
    '**************************************
    This code is AS IS! I had a need For it on a
    project I was working On and found almost no info
    anywhere On what I needed To accomplish. If it
    helps you, great! If it does Not work For you:
    1.Make sure you're Not trying To hit on the same
    pc it's on.
    2.Comment out where the file gets deleted
    (fso.deletefile "c:\" & strIP & ".txt"), To view
    some potential Error info.
    3.Have fun debugging :) (I did)


code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!



    '**************************************
    ' Name: MAC address
    ' Description:Get the clients MAC(Media
    '     Access Control)
    address, a hardware address that uniquely
    identifies Each node of a network. Works great on
    LAN's. Firewalls and Proxy's will be an issue
    depending what side of them you're coding for.
    ' By: Jerry Aguilar
    '
    '
    ' Inputs:None
    '
    ' Returns:Returns the client IP and MAC
    '     address.
    '
    'Assumes:You can't navigate to it runnin
    '     g PWS on the same
    pc but If you are running PWS, you can navigate
    To it from another pc on the same lan (it does
    Not like 127.0.0.1)
    '
    'Side Effects:None
    '
    'Warranty:
    'code provided by Planet Source Code(tm)
    '     (www.Planet-Source-Code.com) 'as is', wi
    '     thout warranties as to performance, fitn
    '     ess, merchantability,and any other warra
    '     nty (whether expressed or implied).
    'Terms of Agreement:
    'By using this source code, you agree to
    '     the following terms...
    ' 1) You may use this source code in per
    '     sonal projects and may compile it into a
    '     n .exe/.dll/.ocx and distribute it in bi
    '     nary format freely and with no charge.
    ' 2) You MAY NOT redistribute this sourc
    '     e code (for example to a web site) witho
    '     ut written permission from the original
    '     author.Failure to do so is a violation o
    '     f copyright laws.
    ' 3) You may link to this code from anot
    '     her website, provided it is not wrapped
    '     in a frame.
    ' 4) The author of this code may have re
    '     tained certain additional copyright righ
    '     ts.If so, this is indicated in the autho
    '     r's description.
    '**************************************
    
    <%@ LANGUAGE="VBSCRIPT"%>
    <%
     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>  

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网