PHP中获取内网用户MAC地址(WINDOWS/linux)的实现代码_php技巧
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;
}
}
函数已经修改过了,到LINUX上发现不能使用EXEC函数,也就是获取不到MAC地址了。经过沟通,该项目必须部署在LINUX服务器下,笔者经过苦思冥想了半天终于找到了一个解决方案,不用执行EXEC也可以获取到内网用户的MAC地址。
在内网服务器中,有一台192.168.1.151的服务器,服务器上一个API,访问这个API,就获取用户MAC,JOSN的方式输出用户账号信息,因为该服务器可以获取MAC,就可以稍加利用了。
使用CURL伪造来源IP方式(IP不是LINUX服务器的IP,是客户端访问的IP地址),CURL到151服务器,服务器得到相应,根据用户IP地址 和ARP -A 参数的正则方式就可以得到客户端的MAC地址,程序运行在151,而151是WINDOWS 2008服务器。但是要注意的是不能使用REMOTE_ADDR,必须使用HTTP_CLIENT_IP。 原因是HTTP_CLIENT_IP可以使用CURL伪造,这样就可以使用LINUX获取用户IP,然后传送给151处理。
疑问:根据用户IP获取MAC地址,那用户换一个IP了怎么办呢?使用CMD下 ARP -A分析,即使用户跟换IP,但是对应该用户的这台计算机的MAC地址默认是不会更换的。
下面是摘抄网友的关于获取IP的文章:
dz的代码判断IP那块太让人头疼了,日,REMOTE_ADDR,HTTP_CLIENT_IP,HTTP_X_FORWARDED_FOR三个东西在手册上太不详细了,基本上就等于没有。
网上gg了一下,找到一点,另外,有一个思路太巧了,用JS取IP以后POST到服务器,Y的用代理骗服务器?有种上网先把Js给关了啊!!哦哈哈,以后有机会用ajax试一下,也省得用这三个变量if得死去活来了。
$_SERVER['...']; // for php
一、没有使用代理服务器的情况:
REMOTE_ADDR = 您的 IP
HTTP_VIA = 没数值或不显示
HTTP_X_FORWARDED_FOR = 没数值或不显示
二、使用透明代理服务器的情况:Transparent Proxies
REMOTE_ADDR = 最后一个代理服务器 IP
HTTP_VIA = 代理服务器 IP
HTTP_X_FORWARDED_FOR = 您的真实 IP ,经过多个代理服务器时,这个值类似如下:203.98.182.163, 203.98.182.163, 203.129.72.215。
这类代理服务器还是将您的信息转发给您的访问对象,无法达到隐藏真实身份的目的。
三、使用普通匿名代理服务器的情况:Anonymous Proxies
REMOTE_ADDR = 最后一个代理服务器 IP
HTTP_VIA = 代理服务器 IP
HTTP_X_FORWARDED_FOR = 代理服务器 IP ,经过多个代理服务器时,这个值类似如下:203.98.182.163, 203.98.182.163, 203.129.72.215。
隐藏了您的真实IP,但是向访问对象透露了您是使用代理服务器访问他们的。
四、使用欺骗性代理服务器的情况:Distorting Proxies
REMOTE_ADDR = 代理服务器 IP
HTTP_VIA = 代理服务器 IP
HTTP_X_FORWARDED_FOR = 随机的 IP ,经过多个代理服务器时,这个值类似如下:203.98.182.163, 203.98.182.163, 203.129.72.215。
告诉了访问对象您使用了代理服务器,但编造了一个虚假的随机IP代替您的真实IP欺骗它。
五、使用高匿名代理服务器的情况:High Anonymity Proxies (Elite proxies)
REMOTE_ADDR = 代理服务器 IP
HTTP_VIA = 没数值或不显示
HTTP_X_FORWARDED_FOR = 没数值或不显示 ,经过多个代理服务器时,这个值类似如下:203.98.182.163, 203.98.182.163, 203.129.72.215。
完全用代理服务器的信息替代了您的所有信息,就象您就是完全使用那台代理服务器直接访问对象。
REMOTE_ADDR 是你的客户端跟你的服务器“握手”时候的IP。如果使用了“匿名代理”,REMOTE_ADDR将显示代理服务器的IP。
HTTP_CLIENT_IP 是代理服务器发送的HTTP头。如果是“超级匿名代理”,则返回none值。同样,REMOTE_ADDR也会被替换为这个代理服务器的IP。
$_SERVER['REMOTE_ADDR']; //访问端(有可能是用户,有可能是代理的)IP
$_SERVER['HTTP_CLIENT_IP']; //代理端的(有可能存在,可伪造)
$_SERVER['HTTP_X_FORWARDED_FOR']; //用户是在哪个IP使用的代理(有可能存在,也可以伪造)

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Introduction: In this article, this website will introduce to you the relevant content about the Mac keyboard not responding when entering passwords. I hope it will be helpful to you, let’s take a look. How to solve the problem that the password cannot be entered on the Apple Mac system? You can also try to connect this keyboard to other computers to see if it works normally. If the same problem occurs on another computer, it's most likely a fault with the keyboard itself. You may consider replacing the keyboard or repairing it. The first time you log in to Alipay with your Mac computer, you will find the login interface and cannot enter your password. The password input field displays: "Please click here to install the control", so Alipay login requires the installation of security controls. Security controls can encrypt and protect the information you enter (amount, password, etc.) to improve account security. Tie

Many Mac users tend to keep the default name of their device and may never consider changing it. Many people choose to stick with the name from the initial setup, such as "Johnny's MacBook Air" or simply "iMac." Learning how to change the name of your Mac is a very useful skill, especially when you have multiple devices, as it can help you quickly distinguish and manage them. Next, we will teach you step by step how to change the computer name, host name and Bonjour name (local host name) in macOS system. Why should you change your Mac name? Changing the name of your Mac can not only show your personality, but also help improve the user experience: Personalize your Mac: The default name may not be to your taste, change it to a name you like.

Introduction: In this article, this website will introduce to you the relevant content about forgetting the password of the Mac installation program. I hope it will be helpful to you, let’s take a look. What to do if you forget your password for Apple computer installation software. First, find iCloud in the phone settings and click to open it. Next, enter your account number and password. There is a line of small words below the login button that prompts you if you have forgotten your ID or password. Click this option. Normally, after you enter an incorrect password multiple times on the login interface, your MacBook Pro will prompt you to use your bound Apple ID to reset your password. You only need to follow the steps prompted by the system to complete the password reset. 3. First shut down your Mac, then restart it. While pressing the power button, immediately press and hold com on the keyboard.

Introduction: Today, this site will share with you relevant content about how to turn pages when typing on Apple Mac. If it can solve the problem you are facing now, don’t forget to follow this site and start now! Tips for using the touchpad on Apple MacBook laptops. The steps for setting up two-finger sliding on Apple computers are as follows: Find the "Settings" icon on the computer desktop and click it. Select "Touchpad" in the settings interface, and then click "Scroll to Zoom". Check "Scroll direction: Natural" in the scroll zoom options to complete the setting. Setting up a two-finger swipe method on your Apple computer is easy. First, turn on your computer and click on the Settings icon at the top of the screen. In the settings interface, select the "Touchpad" option. Then click "Scroll Zoom" and make sure "Scroll Direction" is checked

Preface: Today, this site will share with you the relevant content about installing pkg files on Mac. If it can solve the problem you are facing now, don’t forget to follow this site and start now! The previous version of macos pkg cannot be installed to upgrade the operating system: If your laptop is using an older operating system version, it is recommended to upgrade to the latest operating system version. Because older versions may not support installation of the latest macOS system. Select "Erase" in Disk Utility, then select the Macos extension in the format, do not check the encryption option, and do not select the apfs format, and finally click the "Erase" button to solve the problem of being unable to complete the macOS installation. Drag the application's icon to the file starting with App

Recently, some friends have consulted the editor about how to set up WeChat Mac to automatically convert voice messages into text. The following is a method for setting up WeChat Mac to automatically convert voice messages into text. Friends in need can come and learn more. Step 1: First, open the Mac version of WeChat. As shown in the picture: Step 2: Next, click "Settings". As shown in the picture: Step 3: Then, click "General". As shown in the picture: Step 4: Then check the option "Automatically convert voice messages in chat to text". As shown in the picture: Step 5: Finally, close the window. As shown in the picture:

Preface: Many friends have asked questions about the full screen of the vmmac virtual machine. This article will give you a detailed answer for your reference. I hope it will be helpful to you! Let’s take a look! Mac virtual machine Overwatch has no screen reason: graphics card compatibility issue. If you used to run Overwatch normally but now have a black screen, it may be due to a faulty graphics driver. Solution: Check whether the graphics card supports the game requirements. Update graphics card driver. Try using a different power supply to rule out the second possibility. Check whether there are any abnormalities on the motherboard, such as whether the capacitor is bulged (may have been broken down), whether there is obvious damage to the surface of the motherboard, causing circuit interruption, etc. It is recommended to send the motherboard to a repair station for inspection. If conditions permit, you can consider replacing it with another one.

By default, iPhone takes photos from the camera in HEIC format. HEIC stands for High Efficiency Image Container and can hold more pixel data than PNG or JPG files, taking up significantly less space on iPhone storage compared to other formats. These files work best on iPhones but are not widely accepted on the internet because they often result in blurry/grainy pictures when you share them with non-Apple devices. To ensure that HEIC images are compatible on other devices, you may need to convert them to JPG format. This article will introduce how to convert HEIC images to JPG on Mac. How to Convert HEIC Photos to JPG on Mac [3 Methods] Method
