The realization code _php skill of obtaining intranet user MAC address (windows/linux) in PHP

Source: Internet
Author: User
Tags anonymous curl
Copy Code code as follows:

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;
}
}

function has been modified, to Linux found that can not use the EXEC function, that is, to get the MAC address. After communication, the project must be deployed in the Linux server, the author after a long time to finally find a solution, without executive Exec can also get to the intranet user's MAC address.
In the intranet server, there is a 192.168.1.151 server, server an API, access to the API, the user mac,josn to obtain the way to output user account information, because the server can get Mac, you can use a little.
Using Curl spoofed Source IP (IP is not a Linux server IP, is the IP address of the client access), curl to 151 server, the server is corresponding, according to the user's IP address and arp-a parameters of the regular way can get the client's MAC address, the program runs at 151, And 151 is a Windows 2008 server. However, it is important to note that you cannot use REMOTE_ADDR and you must use HTTP_CLIENT_IP. The reason is that HTTP_CLIENT_IP can use curl forgery, so that you can use Linux to get the user IP and then send it to 151 processing.
Question: According to User IP get MAC address, that user change an IP how to do? Use cmd under ARP-A analysis, even if the user with the IP, but the user should be the MAC address of this computer will not be replaced by default.

Here is a excerpt from the Netizen's article about getting IP:
DZ code to determine IP that block is too annoying, day, remote_addr,http_client_ip,http_x_forwarded_for three things in the manual is too detailed, basically equals No.
Online GG A bit, find a point, in addition, there is a way of thinking too, with JS IP post to the server, Y use Agent to cheat the server? A kind of internet first JS to turn off AH!! Oh haha, later have the opportunity to try with Ajax, also save the use of these three variables if the dead.

$_server[' ... ']; for PHP
First, do not use the proxy server situation:
REMOTE_ADDR = Your IP
Http_via = no value or no display
Http_x_forwarded_for = no value or no display
Second, the use of transparent proxy server situation: transparent proxies
REMOTE_ADDR = Last Proxy server IP
Http_via = Proxy Server IP
Http_x_forwarded_for = Your real IP, after 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 will still be able to forward your information to your Access object, not to hide the real identity.
Third, the use of ordinary anonymous proxy server situation: Anonymous proxies
REMOTE_ADDR = Last Proxy server IP
Http_via = Proxy Server IP
http_x_forwarded_for = Proxy Server IP, after multiple proxy servers, this value is similar to the following: 203.98.182.163, 203.98.182.163, 203.129.72.215.
Hides your real IP, but reveals to the Access object that you are using a proxy server to access them.
Iv. use of deceptive proxy servers: distorting proxies
REMOTE_ADDR = Proxy Server IP
Http_via = Proxy Server IP
Http_x_forwarded_for = Random IP, after multiple proxy servers, this value is similar to the following: 203.98.182.163, 203.98.182.163, 203.129.72.215.
Told the Access object that you used the proxy server, but fabricated a fake random IP instead of your real IP to deceive it.
V. The use of High anonymous proxy server: Gao anonymity proxies (Elite proxies)
REMOTE_ADDR = Proxy Server IP
Http_via = no value or no display
Http_x_forwarded_for = no value or display, after multiple proxy servers, this value is 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, as if you were using that proxy server directly to access the object.

REMOTE_ADDR is the IP of your client when you "shake hands" with your server. If you use anonymous agent, 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 Agent", the None value is returned. Similarly, REMOTE_ADDR will also be replaced with the IP of this proxy server.
$_server[' REMOTE_ADDR ']; IP of the access end (possibly a user, possibly a proxy)
$_server[' Http_client_ip ']; Agent-side (may exist, may be forged)
$_server[' http_x_forwarded_for ']; The user is in which IP to use the proxy (may exist, can also forge)

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.