Search code examples
phplicense-key

How make Licence Key for Mac Address to protect my php application


I am developing hotspot system using php language , and now I want to sell this system but how can I protect my system from be re selling by the buyer and I want to make sure that the license key is used by the right machine with right mac address ,that mean the license key can not be used more than one time. how can I do that , I don't have any idea


Solution

  • MAC address isn't a reliable data source for license binding. In most cases user can change MAC address of the network card, and bypass your security this way.

    You can use more complex algorithm to bind license to the PC. Get motherboard type, CPU type, RAM type, and MAC type. Compute some kind of hash of all this data, and generate license based on it.

    Unfortunatelly, then your legitimate user would change the hardware, he/her would have to inform you and ask for a new license code.

    I assume, that your system is Linux, so you can get all the info about system, by calling shell commands from php.

    Get CPU information:

    $cpu = array_filter(
        array_unique(
            split("\n",
                shell_exec('cat /proc/cpuinfo | grep "model name\|vendor_id"')
            )
        )
    );
    print_r($cpu);
    

    It will output something like:

    Array                                                                   
    (                                                                       
        [0] => vendor_id    : GenuineIntel                                  
        [1] => model name   : Intel(R) Xeon(R) CPU E5-2670 v3 @ 2.30GHz     
    )                                                                       
    

    To get info about motherboard, you can run shell command "sudo dmidecode -t 2" (you'll have to give your php user (www-data) access right to run sudo dmidecode)

    To get memory info, command should be "sudo dmidecode -t 17"