Tips | Client
This procedure belongs to a special method. The scope of use is relatively limited, and there is a certain risk. Borrowed from the ASP in the back door of some methods. The following is the program code.
<%
Dim remoteaddr
if Request.ServerVariables ("Http_x_forwarded_for") =empty then
remoteaddr=request.servervariables ("REMOTE_ADDR")
Else
remoteaddr=request.servervariables ("Http_x_forwarded_for")
End If
Response.Write (Getmac (remoteaddr))
' due to read the NIC MAC address of an IP
' This program reads the MAC address of a specific IP by querying the native ARP table by invoking the ARP command
' Use this procedure to pay attention to the following matters:
' This procedure requires ' WSCRIPT. SHELL "and" Scripting.FileSystemObject "two components, make sure that your server can use both components properly
' This program needs to call the Cmd.exe program, make sure that the IIS Guest account has access to the program.
' This program requires temporary file save results, please ensure that the IIS Guest account has write permission to the temporary directory.
'
function Getmac (IP)
on Error Resume Next
Dim Oscript
Dim Ofilesys, Ofile
Dim all, Sztempfile,ipc,phyc,typec
Dim TempPath
Set oscript = Server.CreateObject ("WSCRIPT. SHELL ")
Set Ofilesys = Server.CreateObject ("Scripting.FileSystemObject")
temppath= "d:\temp\" temporary directory
sztempfile = TempPath & Ofilesys.gettempname () ' Get temporary file name
call Oscript.run ("cmd.exe/c ping-n 2" & IP, 0, True) ' guarantees this IP in the ARP table
call Oscript.run ("cmd.exe/c arp-a" & IP & ">" & Sztempfile, 0, True)
Set ofile = Ofilesys.opentextfile (sztempfile, 1, False, 0)
All=ofile.readall ()
Ofile.close
If (IsObject (ofile)) Then
Call Ofilesys.deletefile (Sztempfile, True)
End If
arr = Split (all, vbCrLf)
If UBound (arr) = 4 Then
IPC = InStr (1, arr (2), "Internet address")
PHYC = InStr (1, arr (2), "Physical Address")
Typec = InStr (1, arr (2), "Type")
If typec > PHYC and PHYC > IPC and IPC > 0 Then
getmac=ucase (Trim (CStr (arr (3), PHYC, TYPEC-PHYC))
End If
End If
End Function
%>