ASP Get Client MAC Address (Source Code)

xiaoxiao2021-03-06  17

From: http://security.zol.com.cn/2005/0218/151064.shtml

This program belongs to a special method. The range of use is limited and there is a risk. Draw some methods in the back door of the ASP. 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 read a network card MAC address of an IP

'This program reads a MAC address of a specific IP by querying the ARP command by querying the ARP table.

'Use this program to pay attention to the following:

'This program requires "WScript.Shell" and "scripting.filesystemObject" two components, make sure your server can use these two components normally

'This program needs to call the cmd.exe program, make sure the IIS guest account has access to the program.

'This program requires a temporary file save result, make sure the IIS guest account is written to the temporary directory.

'

Function GetMac (IP)

ON Error ResMe 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 = Tempp_ ofilesys.gettempname () 'Get temporary file name

Call Oscript.Run ("cmd.exe / c ping -n 2" & IP, 0, true) 'guarantees that this IP is available 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).

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

%>

转载请注明原文地址:https://www.9cbs.com/read-45777.html

New Post(0)