php get mac client
how to get the client computer MAC id using php [duplicate]
For getting the mac ID am using the following code.
But its returns the server mechines MAC ID.. i need to get the MAC iD of the PC in which my webpage runs.
Can anyone help me
4 Answers 4
MAC Addresses are not sent in PHP request headers so you will not be able to access it via that means.
You would need to implement the use of JAVA (NOT Javascript) to get the users connection information.
All internet connecting and networking devices have MAC ID’s this is to identify the device, the manufacturer and the device number.
This would rely on JAVA being implemented to run on the users machine and would be the most reliable way of gathering that information.
You can’t do this in php. Php only ever runs in your server. The only code you can execute on the client machine is JavaScript.
This question is outdated, but as I managed to find it and all other responses are stupid, let it be known that you don’t need to use Java and even though this information is not directly exposed to php scripts, it’s available for every tcp connection in one way or another.
Note that you’re unlikely to get client real mac or ip address for that matter, if he’s behind NAT (which is likely to be the case for most of your users). So usefulness of it is another thing.
Not the answer you’re looking for? Browse other questions tagged php ip client-server or ask your own question.
Linked
Related
Hot Network Questions
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.9.17.40238
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Как я могу получить MAC и IP-адрес подключенного клиента в PHP?
Мне нужно знать MAC и IP-адрес подключаемых клиентов, как я могу это сделать в PHP?
IP-адрес сервера
MAC-адрес сервера
IP-адрес клиента
MAC-адрес клиента
MAC-адрес клиента не будет доступен вам, кроме одного особого обстоятельства: если клиент находится в том же сегменте Ethernet, что и сервер.
Редактировать : вы спрашиваете в комментариях, как получить выход внешней команды – одним из способов является использование обратных ссылок, например
Но что, если клиент не находится в локальной сети?
Ну, вам не повезло, если вы не можете заставить клиента добровольно передавать эту информацию и передавать с помощью других средств.
MAC-адрес клиента (в смысле компьютера, который выдал HTTP-запрос) перезаписывается каждым маршрутизатором между клиентом и сервером.
Иногда, особенно когда вы имеете дело с анонимным прокси, который вы не контролируете, прокси не вернет реальный IP-адрес, и все, на что вы можете надеяться, это IP-адрес прокси-сервера.
Все, что вам нужно сделать, – это включить arp в сложную группу.
И поскольку apache – демон, запущенный под пользовательскими www-данными, теперь он может выполнить эту команду.
Поэтому, если теперь вы используете PHP-скрипт, например:
Для сервера Windows я думаю, что вы можете использовать это:
В окнах, если пользователь использует ваш скрипт локально, это будет очень просто:
Это класс PHP для обработки MAC-адресов поверх операционных систем Unix, Linux и Mac OS X. в основном это было написано, чтобы помочь с подделкой для проверок беспроводной безопасности.
под linux с помощью iptables вы можете записывать в файл каждый запрос на веб-сервер с адресом mac и ip. от php искать последний элемент с IP-адресом и получить MAC-адрес.
Как указано, помните, что адрес mac находится от последнего маршрутизатора на трассе.
Вы можете сделать это легко, используя openWRT. Если вы используете портативный портал, вы можете смешивать php и openWRT и устанавливать связь между IP и маком.
Вы можете написать простой PHP-код, используя:
Там у вас есть mac, IP-адрес и имя хоста.
Это работает для меня в Windows, так как ipconfig /all – это системная команда Windows.
How to get client MAC address when visit to my website?
I need to know the MAC address of the connect clients, how can I do this in PHP?
5 Answers 5
I know this thread is a little old, but I’ve searched a lot of the web trying to find a solutions for the same question. After a LOT of searching the web and a LOT of solutions and codes that never worked, so I wrote the two pieces of code below.
Remember that you can only get the mac address of machines on your lan, there’s no way to get the mac through browser. Hope this might help others also.
The first version above is the most simple I could get.
And the other below is more complex because it brings also if it’s proxied, and hostname.
Once again I just wanted to leave this here to help others in the future.
I dont think it’s possible unless its desktop application running on your user’s machine.
Over the internet, YOU CAN’T. BUT if client is on local network (LAN), create a php file and put this
You can’t, unless the clients themselves send it in the message.
That’s because the MAC Address is a local address that is used for local connections only. A computer uses it to communicate with others devices in its local network (LAN), such as computers, routers, printers, etc. This also means that having the MAC Addresses of the clients is also useless for long communication, since they are not in the same network.
How to get client MAC address by a access on a website?
I have my website, and it records the number of visitors, IP and time of access.
I want to identify each visitor. I think that this was possible recording IP Address. but when the IP is dynamic, my system fails. So I think that I can solve it recording MAC address. is possible? What language should use? PHP, ASP, Javascript?
Edit: What I can use to identify each user without having login information (username & pwd).
4 Answers 4
The MAC address, by TCP/IP standards, is never communicated outside of the local-area network to which it pertains — routers beyond that LAN don’t even get the information you’re trying to record.
There are many other ways to try and identify unique visitors, including matching the user-agent’s details in addition to the IP, serving cookies as part of your response, etc… it is, after all, a core functionality in the field of «web analytics».
MAC addresses are simply not part of the gamut of techniques that it makes sense to utilize for it!
It is only possible if you use a technique where you install a «native» app on the client machine. For example, an activeX component, java applet or a client application. Then that application, once installed can get the MAC and then call to your web server with the MAC as an argument. In other words, you have to build your own front end «browser» to handle logging in. Then once the user is logged in, you can launch the app in the default browser.
It would be nice if future browsers allowed users to give permission to specific sites to access the MAC. Then if a site had a button that said «Register this device» the web application could do so without needing an additional native app installed (after all, the browser IS a native app).
Can’t you just have them store a cookie, so that when they come back they can be uniquely identified? No username/password requirement.
Как получить MAC и IP-адрес подключенного клиента в PHP?
Что такое MAC-адрес?
MAC — это сокращение от «Media Access Control», и это 48-битный физический адрес, связанный с каждым сетевым устройством. Он напечатан на сетевой карте (Network Interface Card) и уникален для любого сетевого устройства. MAC-адрес используется канальным уровнем для маршрутизации пакета данных от источника к месту назначения.
Что такое IP-адрес?
Адрес интернет-протокола (IP), также известный как логический адрес, предоставляется поставщиком интернет-услуг (ISP), который однозначно идентифицирует систему по сети. IP-адрес постоянно меняется время от времени.
// PHP-программа для получения IP-адреса клиента
// Распечатать IP-адрес клиента
?>
Выход:
Примечание. Для онлайновой среды IDE может отображаться ошибка времени выполнения или не отображаются выходные данные, поскольку частные домены не разделяют свои IP-адреса. Для localhost, IP-адрес 127.0.0.1, который является адресом обратной связи, и поэтому IP-адрес клиента: :: 1.
Как получить MAC-адрес подключенного клиента в PHP: «exec ()» — это функция, которая используется для запуска внешней программы в PHP. Возвращает последнюю строку из результата команды. Чтобы получить MAC-адрес, передайте параметр ‘getmac’, который возвращает MAC-адрес клиента. ‘getmac’ — это команда CMD для получения MAC-адреса.
Пример 2: Этот пример получает MAC-адрес с помощью функции exec ().
// PHP-код для получения MAC-адреса клиента
Выход:
Примечание. Этот код не будет работать в онлайн-среде IDE, поскольку getmac — это команда CMD. Попробуйте запустить его на локальном хосте.