(7)

Retrieve local MAC address via PHP

Ever wanted to give out a script that should be restricted to run on one PC? Well, of course you can buy the expensive ioncube pro version which has this feature build in, but the cheaper one ( 199 $ ) also does the job, if you write your own function – which is actually mentioned for windows based systems only.

It’s really not hard, and you can restrict any script to a certain MAC network adapter address. Here’s how to do it:


function getMac(){
exec("ipconfig /all", $output);
foreach($output as $line){
if (preg_match("/(.*)Physical Address(.*)/", $line)){
$mac = $line;
$mac = str_replace("Physical Address. . . . . . . . . :","",$mac);
}
}
return $mac;
}

$mac = getMac();
$mac = trim($mac);

After that, you only need to know the MAC address of the PC the script should run on, and compare that string to the one retrieved. To make the script really secure, you will have to obfuscate it, which can be done by any free PHP encoder or the splendid tool from ioncube.

Filed under: Programming — admin @ 1:05 pm
 

7 Comments »

  1. Comment by saeed othman

    May 23, 2008

    Dear sir
    i just like to say,,, Thaaaaaaaaaaaaaaaank you…
    i passed a huge time and effort while searching on this issue,,,,
    thank you very very much

    and i hope that you have no problem if i ask you for any help in the future

    You#re welcome Saeed. And no – no problem at all, if you have questions, simply drop in a line :)

  2. Comment by moka

    November 19, 2008

    Hey! Thanks for your idea!
    You mentioned this script is “windows based”, does that mean that is work only on windows? Does it work on other OSs, like Linux or Mac?

    Thanks in advice!

  3. Comment by ergonomic-backpack

    January 8, 2009

    This is a good post, i’m searching around.
    I think using MAC address could prevent unauthorized to access your system admin.

  4. Comment by Shelon Padmore

    May 10, 2009

    It’s also handy to check the machine ID. This is even more fool proof than the MAC which can be cloned.

    - Shelon Padmore

  5. Comment by Kevin

    October 21, 2009

    Thank you so very much!!!

  6. Comment by Akilanda Nageswari

    January 4, 2010

    Dear sir
    i just like to say,,, Thank you very much …
    thanks alot to give that queries. i passed a huge time and effort while searching on this issue,,,,
    thank you very very much

    i have another one query sir can u help me..

    how i detect hardware and software information using php sir in windows OS ??
    How i find the speed of the internet ?? in php
    how i show the lan system in php

  7. Comment by Jenn

    January 7, 2010

    Perfect thanks a million.

RSS feed for comments on this post. TrackBack URL

Leave a comment

copyright © 2010 artViper designstudio, all rights reserved

Latest twitter news

TweetMeme | Sun Feb 28

RT @nettuts Top 20+ MySQL Best Practices - Nettuts+ http://bit.ly/6C4FqG

TweetMeme | Wed Feb 24

RT @mashable Typekit Launches its Cloud-Based Web Font Service http://bit.ly/4w68Ub

TweetMeme | Wed Feb 24

RT @tweetmeme 3 New Ways to Measure the Social Web http://ow.ly/1o0cfQ

Random posts

09-09-17 | Bumpbox | lightbox alternative | PDF SWF FLV ...

Bumpbox is an alternative lightbox which can handle the formats SWF, FLV, images, HTML and PDF. The animation of the boo...

09-09-19 | tag cloud to flash tag cloud converter ...

Thesedays many blog users have this nice flash tag cloud on their page. Just too bad it works only with a few systems li...

08-02-23 | mooDBToolTip - DB driven tooltips with AJAX a ...

mooDBToolTip is an AJAX & PHP driven solution to populate a toolTip for a specific link or tag in your website automatic...