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 pl.net source code(tm)
' (www.pl.net-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>
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器