Getting MAC Address using PHP

<?php
/*
* Getting MAC Address using PHP
* Md. Nazmul Basher
*/

ob_start(); // Turn on output buffering
system(‘ipconfig /all’); //Execute external program to display output
$mycom=ob_get_contents(); // Capture the output into a variable
ob_clean(); // Clean (erase) the output buffer

$findme = “Physical”;
$pmac = strpos($mycom, $findme); // Find the position of Physical text
$mac=substr($mycom,($pmac+36),17); // Get Physical Address

echo $mac;
?>

15 Responses to Getting MAC Address using PHP

  1. Excellent… If you explain major lines will be helpful for all.

    Cheers!!!!!

  2. Hi Nazmul Basher,

    Excellent code!
    Can you tell me how can i get implemented over intranet…
    I have an application user’s based, every user login in that application and interact with this… how can i track them via mac address….

    Keep it up bro,
    warm regards
    Naseer Ahmad
    Pakistan

  3. Saurabh Goyal says:

    Hi,
    Thank’s for this script .I really forgot use of output buffering in php.
    I try to ur MAC address using js but it give me error i.e automated server canot create object.

    Regard’s

    Saurabh Goyal
    http://webexpert.wordpress.com

  4. Shaikh Sonny Aman says:

    I think the script will return the mac address of the server not of the client, isn’t it?
    and the server must run on windows os, right? that also mean it should not work on other os like linux!?

    plz rectify me if I am wrong.

    thanks for the code, its a nice hack🙂

  5. Siridion M. Cabudlan says:

    Excellent codes!
    Thank you sir for your Codes!

  6. Tejas Shah says:

    hi,
    thanks for this useful script.
    i wanna generate licence for s/w and this infi is very useful for me.
    thanks again,
    regards,
    Tejas Shah

  7. Long Nguyen says:

    Thank you for this code! It’s very excellent and helpfull for me.
    Long Nguyen

  8. amit says:

    This will be useful for me to use in my wordpress plugin for licence checking😉 thanks man

  9. Farhad Uddin says:

    Thank you

  10. Aminu Abdulsalami says:

    Great Programmer, thanks for this code

  11. namdp06 says:

    thank you for amazing code

  12. Khalid says:

    Thanks Youuuuuuuuuuuuuuuuuuuuuuuu Amazinggggggggggggg…..

  13. Barok says:

    Thank’s,.,.,

  14. Asik says:

    many many thanks….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: