<%@ LANGUAGE="VBSCRIPT"%>
<%
strIP = Request.ServerVariables("REMOTE_ADDR")
strMac = GetMACAddress(strIP)

strMac = GetMACAddress("192.168.200.170")
'strHost = Request.ServerVariables("REMOTE_HOST")
response.write "<BR>Client IP = " & strIP
response.write "<BR>Client Mac Address = " & strMac
response.write "<BR>Host = " & strHost

if strMac = "" then
%>
<script language=javascript>
alert("Client 의 MacAddress 정보가 없습니다!")
history.back(-1)
</script>
<%
Response.End()
else
url = "./setUserMacInfo.aspx?MacAddr=" & strMac
end if

Response.Redirect( url )


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
%>

Posted by 퓨전마법사
,