This program is a special method. The scope of use is relatively limited, and there is a certain risk. Some methods in asp backdoors are used for reference. 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 ))
'The MAC address of the NIC that reads an IP address
'The program reads the MAC address of a specific IP address from the local arp table by calling the arp command.
'Note the following when using this program:
'The program requires two components: "WSCRIPT. SHELL" and "Scripting. FileSystemObject". Make sure that your server can use these two components normally.
'The local program uses the cmd.exe program. Make sure that the IIS guest account has permission to access the program.
'This program requires temporary files to save the results. Make sure that the IIS guest account has the write permission 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: emp" '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 address exists 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
%>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service