4

is there a way i can get hard disk serial number or machine serial number with php or javascript on localhost ??

we can get it with following command in cmd

wmic DISKDRIVE GET SerialNumber

or machine serial number by this

wmic bios get serialnumber

is that possible with php or javascript ?? something in php

<?php

echo DISKDRIVE GET SerialNumber //** some thing like this on local host

?>

Need is to give a project to Clint on local host, and i want no one to access it on other computer (in php)

Charles
  • 50,943
  • 13
  • 104
  • 142
Harinder
  • 1,257
  • 8
  • 27
  • 54
  • Not possible! Otherwise would be a big security flaw! – Ben Carey Dec 10 '12 at 08:03
  • 4
    What does "on localhost" mean? On the *server* or on the *client*? – deceze Dec 10 '12 at 08:04
  • In IE you can use ActiveX.. the user will have to give permission for this to execute. Maybe there is a possibility? – Wouter de Kort Dec 10 '12 at 08:04
  • @WouterdeKort This will most likely need to be browser compatible – Ben Carey Dec 10 '12 at 08:05
  • Make an application and ask the users to download an run it? – Salman A Dec 10 '12 at 08:06
  • Its not possible. Check some inputs here http://stackoverflow.com/questions/709108/getting-serial-number-of-the-hard-drive-provided-by-the-manufacturer-through-php – kiranvj Dec 10 '12 at 08:20
  • @deceze its local host on my pc – Harinder Dec 10 '12 at 08:37
  • 1
    You can of course use `shell_exec('wmic DISKDRIVE GET SerialNumber 2>&1')` or `shell_exec('wmic bios get serialnumber 2>&1')` if wmic is installed on server and your PHP has permission to run it. The '2>&1' part is used from the [suggestion here](http://php.net/manual/en/function.shell-exec.php#106250). – Lenin Dec 10 '12 at 08:38
  • 1
    @Lenin thx bro it worked ... can u make it and not comment so i can accept it and close this question – Harinder Dec 10 '12 at 08:42
  • Great that it worked. I do not have wmic installed so I couldn't check it myself. – Lenin Dec 10 '12 at 08:46
  • @Harinder That doesn't mean anything. In web programming, you're either talking about **the server** or **the client**. It doesn't matter whether that's your own computer or both are the same machine or not. – deceze Dec 10 '12 at 08:49
  • @deceze Sorry its server .... ;) – Harinder Dec 10 '12 at 08:54

2 Answers2

7

You can of course use

shell_exec('wmic DISKDRIVE GET SerialNumber 2>&1')

or

shell_exec('wmic bios get serialnumber 2>&1') 

if wmic is installed on server and your PHP has permission to run it.

The '2>&1' part is used from the suggestion here.

Shahzad Barkati
  • 2,532
  • 6
  • 25
  • 33
Lenin
  • 570
  • 16
  • 36
  • 1
    And just a FYI, shell_exec has a variant with [backtick operator](http://php.net/manual/en/language.operators.execution.php) in php. – Lenin Dec 10 '12 at 08:49
2

impossblie. Nothing can break the browser sandbox, otherwize it will be a big security problem.

The only possibility is via ActiveX , but still need to signature and change the IE settings. (no cross platform, not cross browser)

ray_linn
  • 1,382
  • 10
  • 14