get the clients mac(media access control) address, a hardware address that uniquely identifies each
node of a network. works great on lans. firewalls and proxys will be an issue depending what side of
them youre coding for.
cant 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 youre not trying to hit on the same
pc its 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:
cant 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
lans. firewalls and proxys will be an issue
depending what side of them youre coding for.
by: jerry aguilar
inputs:none
returns:returns the client ip and mac
address.
assumes:you cant 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
rs 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>
