By
Arun
Physical Address Transport Name
=================== ==========================================================
00-90-F5-E8-75-02 Media disconnected
0C-8B-FD-4E-5B-DD \Device\Tcpip_{8482B1C2-8314-4309-9547-ADF8E3C6A222}
08-00-27-00-7C-C5 \Device\Tcpip_{E12D9144-FFA9-4394-9FEC-1CF6E5D36E82}
Actul this code copy from site.....
code given below
.......................
class GetMacAddr{
var $return_array = array(); // ????MAC???????
var $mac_addr;
function GetMacAddr($os_type){
switch ( strtolower($os_type) ){
case "linux":
$this->forLinux();
break;
case "solaris":
break;
case "unix":
break;
case "aix":
break;
default:
$this->forWindows();
break;
}
$temp_array = array();
foreach ( $this->return_array as $value ){
if (preg_match("/[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f][:-]"."[0-9a-f][0-9a-f]/i",$value,
$temp_array ) ){
$this->mac_addr = $temp_array[0];
break;
}
}
unset($temp_array);
return $this->mac_addr;
}
function forWindows(){
@exec("ipconfig /all", $this->return_array);
if ( $this->return_array )
return $this->return_array;
else{
$ipconfig = $_SERVER["WINDIR"]."\system32\ipconfig.exe";
if ( is_file($ipconfig) )
@exec($ipconfig." /all", $this->return_array);
else
@exec($_SERVER["WINDIR"]."\system\ipconfig.exe /all", $this->return_array);
return $this->return_array;
}
}
function forLinux(){
@exec("ifconfig -a", $this->return_array);
return $this->return_array;
}
}
//????
$mac = new GetMacAddr(PHP_OS);
$mac=$mac->mac_addr;
please try it...
I want to get ethernet macaddress it's wifi address
Now try this type code but need a help, How to get mac address from wscript.shell
to a string
No idea about how this code work.
$shell = new COM("WScript.Shell") or die("Requires Windows Scripting Host");
$some = $shell->run(getmac);
C:\Users\ctomczak>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : ctomczak-PC
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
Ethernet adapter Local Area Connection* 19:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Juniper Network Connect Virtual Adapter
Physical Address. . . . . . . . . : 00-FF-50-E4-1E-0D
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Wireless LAN adapter Wireless Network Connection:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Intel(R) Wireless-N 7260
Physical Address. . . . . . . . . : 0C-8B-FD-4E-5B-DD
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::f455:a760:b0e5:4c13%13(Preferred)
IPv4 Address. . . . . . . . . . . : 192.168.0.13(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Lease Obtained. . . . . . . . . . : Friday, May 09, 2014 7:45:13 AM
Lease Expires . . . . . . . . . . : Friday, May 16, 2014 7:45:17 AM
Default Gateway . . . . . . . . . : 192.168.0.1
DHCP Server . . . . . . . . . . . : 192.168.0.1
DHCPv6 IAID . . . . . . . . . . . : 386698237
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-1A-0A-4D-46-00-90-F5-E8-75-02
DNS Servers . . . . . . . . . . . : 62.179.1.61
62.179.1.63
NetBIOS over Tcpip. . . . . . . . : Enabled
That's not stable to work with an application so find another idea share with us....Now am use to lock my application via system mac address but it also some drawbacks some time get mac or some time fetch mac of WiFi or ether-net like that...so not completely dependable. Czarek Tomczak say to use UUID i check this idea but error occurred one of my system how it will solved:
C:\Documents and Settings\user>wmic path win32_computersystemproduct get uuid
'wmic' is not recognized as an internal or external command,
operable program or batch file.
C:\Windows\System32\wbem\wmic.exe path win32_computersystemproduct get uuid
I tried this and no good:
$shell = new COM("WScript.Shell") or die("Requires Windows Scripting Host");
$getUUID= $shell->Run("C:\Windows\System32\wbem\wmic.exe path win32_computersystemproduct get uuid");
echo "this is PC's UUID: $getUUID";
and all i get is:
this is PC's UUID: 0
it does popup for a split second a command line with what looks like the correct info but no idea how to capture the data any help?
- The MSDN page states that if uuid is not available, a UUID of all zeros is used.
You have to decide which ones will decide about uniqueness of a computer. You may want to query several of them and not depend only on one, as sometimes it may not be available, or be of zeroes like uuid.
ob_start();
$ret = system("C:\Windows\System32\wbem\wmic.exe path win32_computersystemproduct get uuid");
$output = ob_get_contents();
ob_end_clean();
if ($ret !== false) {
echo "Command executed successfully.<br>";
echo "Output: $output";
} else {
echo "Command failed.";
}
Bat file:
@echo off
cls
setlocal EnableDelayedExpansion
:: now lets get UUIDD
wmic csproduct get UUID >output.tmp
Type output.tmp | findstr /I /V /C:"UUID">>UUID.tmp
for /f "tokens=1*delims=:" %%G in ('findstr /n "^" UUID.tmp') do if %%G equ 1 SET UUID=%%H
echo UUID=%UUID% >user.txt
echo USER=%USERNAME% >>user.txt
:: now delete tmp file(s)
Del output.tmp
Del UUID.tmp
EXIT
------
I got the username just in case as well... and then in my php i did this:
<?php
// now lets get uuid info using bat file
$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run('cmd /C user/getUserInfo.bat', 2, false);
unset($WshShell, $oExec);
// lets get user settings
$myFile = "user/user.txt";
$lines = file($myFile);//file in to an array
$get= $lines[0];
$split = explode("=", $get);
$UUIDD = $split['1'];
?>
----------------------
i am sure there is a better way but for now it works, any suggestions is great
$info = array(); $uuid = shell_exec("echo | {$_ENV['SYSTEMROOT']}\System32\wbem\wmic.exe path win32_computersystemproduct get uuid"); $lines = explode("\n", $uuid); $info['UUID'] = trim($lines[1]); $output = shell_exec("echo | ipconfig/all"); if ($output) { $lines = explode("\n", $output); $group = ''; foreach($lines as $line){ if(strpos($line, " . ") !== FALSE) { $key = str_replace('.','',trim(substr($line,0,strpos($line, " . ")))); $value = trim(substr($line,strpos($line, " : ") + 3)); $info[$group]["{$key}"] = "{$value}"; } else if(!empty($line)){ if(substr($line,0,1) == ' '){ }else{ $group = $line; $info["$group"] = array(); } } else {
} } }
echo '<pre>'; print_r($info); echo '</pre>';