This procedure is a special method. The scope of use is relatively limited and there is a certain degree of danger. Learned some methods from the asp backdoor. Below 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 reading the network card MAC address of a certain IP
'This program reads the MAC address of a specific IP by calling the arp command and querying the local arp table.
'Please note the following when using this program:
' This program requires two components: "WSCRIPT.SHELL" and "Scripting.FileSystemObject". Please ensure that your server can use these two components normally.
' This program needs to call the cmd.exe program. Please ensure that the IIS guest account has access rights to the program.
' This program requires temporary files to save results. Please ensure that the IIS guest account has write permissions on 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 the temporary file name
Call oScript.Run ("cmd.exe /c ping -n 2 " & IP, 0, True) ' Ensure that this IP is 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(Mid(arr(3), phyc, typec - phyc))))
End If
End If
End function
%>