2

php code:

$sys = system('dir');

I have searched for days now, cannot come to a satisfying conclusion. All over the internet, the php code above is common or the other one here shell_exec('dir');. These two php codes gets the server directory files.

first step: In command prompt (cmd) on windows computers, if you input wmic bios get serialnumber you will get the serial number of your computer bios serial number.

Now, if an employee access through the company website at work for work purposes, How do we get the bios serial number by executing the cmd and get the wmic bios get serialnumber output for log purposes for employees. Or any other method to ID the internet devices that each employee uses for daily inventory and log purposes for a company.

Direction: If we can execute the cmd on client side and execute this command like this (only for logged in users):

$ip  = $_SERVER['REMOTE_ADDR'];
$mac = shell_exec('arp -a ' . escapeshellarg($ip));

OR

$mac = system('ipconfig/all');

and then grep the mac address somewhere. However, the purpose of this is to log our internet devices use by workers in the factories. Any help of direction in another way or in a different way to identify uniquely identify an internet device would be great. php, javascript, etc. Thank you.

  • Are you asking to get the serial of the server running php or the client accessing it? Also what IS? I suspect you cant do what you are trying, but.might misunderstand. – davidgo Jan 26 at 1:54
  • @davidgo thank you for the comment. I am actually looking for a way to get an ID of employees computer as log for our record. Sort kind of collecting data log kind of ....if you know what I mean – A. Kiyoshi Jan 26 at 2:02
  • No idea what you mean, but php is not the tool for the job - in fact any decent web client (like Mozilla or Firefox will block this behaviour regardless of the app) – davidgo Jan 26 at 4:54
  • @davidgo thank you for the reply. I just put that up and an example, but It doesnt have to be php. It could be either a javascript, a php function, etc. any help of direction would help. thank you – A. Kiyoshi Jan 26 at 5:02
  • As both I and @Journeymangeek already stated you cant do this in the general case through a web browser without the user running a program (or possibly browser plugin). Think about it - someone who can run arbitrary code on your PC can hijack it - the last thing a browser wants to allow. – davidgo Jan 26 at 5:11
7

There's really good reasons you don't want to run arbitrary code on a client side system - if you can run wmic bios get serialnumber you could also run a virus, ransomware or other nasty stuff. Being able to identify a specific PC is also undesirable for privacy reasons. There's a good reason being able to uniquely identify a PC is a holy grail for companies - ranging from uniquely fingerprinting systems (panopticlick is a great example designed to show what companies do.

In short - its not possible, and it would be horrifying securitywise if it was. There's no reason a web server should/could be allowed to run arbitrary code and get uniquely identifying system on a client.

  • ahh thank you, I really appreciate it. I am looking for a way to get an ID of a certain computer like who is using which, sort kind of information. Can you advice on that please? Its for employees log information required at work... – A. Kiyoshi Jan 26 at 2:01
  • 1
    If you are looking to ensure the computer is authorised to the server, dont look to PHP. Use the web server and build a CA and issue client side certs which the server can validate. – davidgo Jan 26 at 2:05
  • Get them to log in, and use that. The simplest solution is often the best. – Journeyman Geek Jan 26 at 2:07
  • @JourneymanGeek thank you, we log the attendance of all employees through log in. We also wish to take more of an inventory or who is using which internet device since we use ipads, pc, etc. Its a factory and everybody using an internet device. Please if you guys have a clue on how to ID the device please advice – A. Kiyoshi Jan 26 at 2:20
  • 1
    @JourneymanGeek Thank you for the heads up, really appreciate it. If you have any other way how to ID a computer that is connected to the internet, and the user has logged in to your website, this would be of a great help. In any language whether php or any other ways would be helpful. Thank you – A. Kiyoshi Jan 26 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.