Implementation code for obtaining intranet user MAC address (WINDOWS/linux) in windows live messenger 2011 PHP

WBOY
Release: 2016-07-29 08:46:31
Original
875 people have browsed it

复制代码代码如下:


function ce_getmac()
{
if(PHP_OS == 'WINNT')
{
$return_array = array();
$temp_array = array();
$mac_addr = "";
@exec("arp -a",$return_array);
foreach($return_array as $value)
{
if(strpos($value,$_SERVER["HTTP_CLIENT_IP"]) !== false &&
preg_match("/(:?[0-9a-f]{2}[:-]){5}[0-9a-f]{2}/i",$value,$temp_array))
{
$mac_addr = $temp_array[0];
break;
}
}
return $mac_addr ? strtoupper($mac_addr) : '';
}
else if(PHP_OS == 'Linux')
{
return true;
}
}


The function has been modified. I found that the EXEC function cannot be used on LINUX, which means that the MAC address cannot be obtained. After communication, the project must be deployed under a LINUX server. After thinking hard for a long time, the author finally found a solution. The MAC address of the intranet user can be obtained without executing EXEC.
In the intranet server, there is a server at 192.168.1.151. There is an API on the server. When accessing this API, the user's MAC is obtained and the user account information is output in JOSN mode. Because the server can obtain the MAC, it can be used a little bit. .
Use CURL to forge the source IP (the IP is not the IP of the LINUX server, but the IP address accessed by the client), CURL to the 151 server, the server gets the response, and the client can be obtained according to the regular method of the user IP address and ARP -A parameters MAC address, the program runs on 151, and 151 is the WINDOWS 2008 server. But it should be noted that REMOTE_ADDR cannot be used, HTTP_CLIENT_IP must be used. The reason is that HTTP_CLIENT_IP can be forged using CURL, so that LINUX can be used to obtain the user IP and then sent to 151 for processing.
Question: Obtain the MAC address based on the user's IP. What should I do if the user changes his IP? Using ARP -A analysis under CMD, even if the user changes IP, the MAC address of the computer corresponding to the user will not be changed by default.
The following is an excerpt from a netizen's article about obtaining IP:
Dz's code to determine the IP is too troublesome. The three things, REMOTE_ADDR, HTTP_CLIENT_IP, and HTTP_X_FORWARDED_FOR, are not detailed in the manual, and they are basically missing.
I searched online and found something. In addition, there is an idea that is too clever. Use JS to get the IP and then POST to the server. How about using a proxy to deceive the server? If you have the guts to go online, turn off JS first! ! Oh haha, I will try it with ajax if I have a chance in the future, and I won’t have to worry about using these three variables if.
$_SERVER['...']; // for php
1. When no proxy server is used:
REMOTE_ADDR = your IP
HTTP_VIA = no value or not displayed
HTTP_X_FORWARDED_FOR = no value or no display
2. When using a transparent proxy server: Transparent Proxies
REMOTE_ADDR = Last proxy server IP
HTTP_VIA = Proxy server IP
HTTP_X_FORWARDED_FOR = Your real IP. When passing through multiple proxy servers, this value is similar to the following: 203.98.182.163, 203.98.182.163 , 203.129.72.215.
This type of proxy server still forwards your information to your visitor, which cannot achieve the purpose of hiding your true identity.
3. The situation of using ordinary anonymous proxy servers: Anonymous Proxies
REMOTE_ADDR = Last proxy server IP
HTTP_VIA = Proxy server IP
HTTP_X_FORWARDED_FOR = Proxy server IP. When passing through multiple proxy servers, this value is similar to the following: 203.98.182.163, 203.98.182.163, 203.129.72.215.
Hide your real IP, but reveal to your visitors that you are using a proxy server to access them.
4. The use of deceptive proxy servers: Distorting Proxies
REMOTE_ADDR = proxy server IP
HTTP_VIA = proxy server IP
HTTP_X_FORWARDED_FOR = random IP. When passing through multiple proxy servers, this value is similar to the following: 203.98.182.163, 203.98. 182.163, 203.129.72.215.
Tell the person you are visiting that you are using a proxy server, but make up a fake random IP instead of your real IP to spoof it.
5. Situation of using high anonymity proxy server: High Anonymity Proxies (Elite proxies)
REMOTE_ADDR = Proxy server IP
HTTP_VIA = No value or not displayed
HTTP_X_FORWARDED_FOR = No value or not displayed. When passing through multiple proxy servers, this value Similar to the following: 203.98.182.163, 203.98.182.163, 203.129.72.215.
Completely replaces all your information with the proxy server's information, just like you are using that proxy server to directly access the object.
REMOTE_ADDR is the IP when your client "handshakes" with your server. If an "anonymous proxy" is used, REMOTE_ADDR will display the IP of the proxy server.
HTTP_CLIENT_IP is the HTTP header sent by the proxy server. If it is a "super anonymous proxy", a value of none is returned. Likewise, REMOTE_ADDR will be replaced with the IP of this proxy server.
$_SERVER['REMOTE_ADDR']; //Accessing end (may be user, may be proxy) IP
$_SERVER['HTTP_CLIENT_IP']; //Agent end (may exist, can be forged)
$_SERVER ['HTTP_X_FORWARDED_FOR']; //Which IP does the user use as a proxy (may exist or can be forged)

The above introduces the implementation code for obtaining the MAC address of intranet users (WINDOWS/linux) in Windows Live Messenger 2011 PHP, including the content of Windows Live Messenger 2011. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!